diff --git a/mozilla/accessible/src/atk/nsAccessibleHyperText.cpp b/mozilla/accessible/src/atk/nsAccessibleHyperText.cpp index ac34de93f89..faa26d0f1b9 100644 --- a/mozilla/accessible/src/atk/nsAccessibleHyperText.cpp +++ b/mozilla/accessible/src/atk/nsAccessibleHyperText.cpp @@ -75,11 +75,10 @@ nsAccessibleHyperText::nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakRefere nsIFrame *parentFrame = nsAccessible::GetParentBlockFrame(frame); NS_ASSERTION(parentFrame, "Error: HyperText can't get parent block frame"); if (parentFrame) { - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); nsIFrame* childFrame = parentFrame->GetFirstChild(nsnull); PRBool bSave = PR_FALSE; - GetAllTextChildren(presContext, childFrame, aDomNode, bSave); + GetAllTextChildren(shell->GetPresContext(), childFrame, + aDomNode, bSave); } } } diff --git a/mozilla/accessible/src/atk/nsAccessibleText.cpp b/mozilla/accessible/src/atk/nsAccessibleText.cpp index ce6452002ec..e9935f9ef99 100644 --- a/mozilla/accessible/src/atk/nsAccessibleText.cpp +++ b/mozilla/accessible/src/atk/nsAccessibleText.cpp @@ -104,9 +104,8 @@ nsresult nsAccessibleText::GetSelections(nsISelectionController **aSelCon, nsISe // Get the selection and selection controller nsCOMPtr selCon; nsCOMPtr domSel; - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); - frame->GetSelectionController(context, getter_AddRefs(selCon)); + frame->GetSelectionController(shell->GetPresContext(), + getter_AddRefs(selCon)); if (selCon) selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)); @@ -648,8 +647,7 @@ NS_IMETHODIMP nsAccessibleText::GetCharacterExtents(PRInt32 aOffset, nsIPresShell *shell = doc->GetShellAt(0); NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = shell->GetPresContext(); NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); nsCOMPtr content(do_QueryInterface(mTextNode)); diff --git a/mozilla/accessible/src/base/nsAccessNode.cpp b/mozilla/accessible/src/base/nsAccessNode.cpp index 6247d0126c8..ad40920592d 100755 --- a/mozilla/accessible/src/base/nsAccessNode.cpp +++ b/mozilla/accessible/src/base/nsAccessNode.cpp @@ -213,7 +213,9 @@ void nsAccessNode::ShutdownXPAccessibility() already_AddRefed nsAccessNode::GetPresShell() { - nsCOMPtr presShell(do_QueryReferent(mWeakShell)); + nsIPresShell *presShell = nsnull; + if (mWeakShell) + CallQueryReferent(mWeakShell.get(), &presShell); if (!presShell) { if (mWeakShell) { // If our pres shell has died, but we're still holding onto @@ -223,20 +225,16 @@ already_AddRefed nsAccessNode::GetPresShell() } return nsnull; } - nsIPresShell *resultShell = presShell; - NS_IF_ADDREF(resultShell); - return resultShell; + return presShell; } -already_AddRefed nsAccessNode::GetPresContext() +nsPresContext* nsAccessNode::GetPresContext() { nsCOMPtr presShell(GetPresShell()); if (!presShell) { return nsnull; } - nsPresContext *presContext; - presShell->GetPresContext(&presContext); // Addref'd - return presContext; + return presShell->GetPresContext(); } already_AddRefed nsAccessNode::GetDocAccessible() @@ -410,7 +408,7 @@ NS_IMETHODIMP nsAccessNode::GetComputedStyleValue(const nsAString& aPseudoElt, const nsAString& aPropertyName, nsAString& aValue) { nsCOMPtr domElement(do_QueryInterface(mDOMNode)); - nsCOMPtr presContext(GetPresContext()); + nsPresContext *presContext = GetPresContext(); NS_ENSURE_TRUE(domElement && presContext, NS_ERROR_FAILURE); nsCOMPtr container = presContext->GetContainer(); diff --git a/mozilla/accessible/src/base/nsAccessNode.h b/mozilla/accessible/src/base/nsAccessNode.h index fd032905394..a18c9604dbf 100755 --- a/mozilla/accessible/src/base/nsAccessNode.h +++ b/mozilla/accessible/src/base/nsAccessNode.h @@ -122,7 +122,7 @@ class nsAccessNode: public nsIAccessNode, public nsPIAccessNode protected: nsresult MakeAccessNode(nsIDOMNode *aNode, nsIAccessNode **aAccessNode); already_AddRefed GetPresShell(); - already_AddRefed GetPresContext(); + nsPresContext* GetPresContext(); already_AddRefed GetDocAccessible(); virtual nsIFrame* GetFrame(); diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index 1f5f81d1414..66dc489ed01 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -839,12 +839,11 @@ nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessi return NS_ERROR_FAILURE; nsCOMPtr presShell(do_QueryReferent(weakShell)); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); nsIFrame* childFrame = parentFrame->GetFirstChild(nsnull); PRInt32 index = 0; nsIFrame* firstTextFrame = nsnull; - PRBool ret = nsAccessible::FindTextFrame(index, presContext, childFrame, &firstTextFrame, frame); + PRBool ret = nsAccessible::FindTextFrame(index, presShell->GetPresContext(), + childFrame, &firstTextFrame, frame); if (!ret || index != 0) return NS_ERROR_FAILURE; diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 5f51a95fc6c..9ac801e93d4 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -514,8 +514,7 @@ PRBool nsAccessible::IsPartiallyVisible(PRBool *aIsOffscreen) return PR_FALSE; } - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = shell->GetPresContext(); if (!presContext) return PR_FALSE; @@ -770,7 +769,7 @@ NS_IMETHODIMP nsAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PR // Another frame, same node <- Example // Another frame, same node - nsCOMPtr presContext(GetPresContext()); + nsPresContext *presContext = GetPresContext(); if (!presContext) { *x = *y = *width = *height = 0; @@ -1381,8 +1380,7 @@ nsresult nsAccessible::GetParentBlockNode(nsIPresShell *aPresShell, nsIDOMNode * if (! parentFrame) return NS_ERROR_FAILURE; - nsCOMPtr presContext; - aPresShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = aPresShell->GetPresContext(); nsIAtom* frameType = nsnull; while (frame && (frameType = frame->GetType()) != nsAccessibilityAtoms::textFrame) { frame = frame->GetFirstChild(nsnull); diff --git a/mozilla/accessible/src/base/nsCaretAccessible.cpp b/mozilla/accessible/src/base/nsCaretAccessible.cpp index 0c7733cb643..ce28434313e 100644 --- a/mozilla/accessible/src/base/nsCaretAccessible.cpp +++ b/mozilla/accessible/src/base/nsCaretAccessible.cpp @@ -104,8 +104,7 @@ NS_IMETHODIMP nsCaretAccessible::AttachNewSelectionListener(nsIDOMNode *aCurrent nsIFrame *frame = nsnull; presShell->GetPrimaryFrameFor(content, &frame); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if (!frame || !presContext) return NS_ERROR_FAILURE; @@ -159,8 +158,7 @@ NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, ns nsIAccessibleEvent::EVENT_HIDE, this, nsnull); } - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); nsIViewManager* viewManager = presShell->GetViewManager(); if (!presContext || !viewManager) return NS_OK; diff --git a/mozilla/accessible/src/base/nsDocAccessible.cpp b/mozilla/accessible/src/base/nsDocAccessible.cpp index 3bce7378088..9e232621033 100644 --- a/mozilla/accessible/src/base/nsDocAccessible.cpp +++ b/mozilla/accessible/src/base/nsDocAccessible.cpp @@ -516,10 +516,6 @@ nsresult nsDocAccessible::AddEventListeners() } } - nsCOMPtr context; - presShell->GetPresContext(getter_AddRefs(context)); - NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); - mWebProgress = do_GetInterface(docShellTreeItem); NS_ENSURE_TRUE(mWebProgress, NS_ERROR_FAILURE); diff --git a/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp b/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp index 91e283d1272..afd5ab32c3e 100644 --- a/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLAreaAccessible.cpp @@ -114,7 +114,7 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *w *x = *y = *width = *height = 0; - nsCOMPtr presContext(GetPresContext()); + nsPresContext *presContext = GetPresContext(); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); nsCOMPtr ourContent(do_QueryInterface(mDOMNode)); diff --git a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp index 9de909a5641..81f4ebd9df2 100644 --- a/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -353,7 +353,7 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetState(PRUint32 *_retval) nsIFrame *frame = GetFrame(); if (frame) { - nsCOMPtr context(GetPresContext()); + nsPresContext *context = GetPresContext(); NS_ENSURE_TRUE(context, NS_ERROR_FAILURE); nsCOMPtr selCon; frame->GetSelectionController(context,getter_AddRefs(selCon)); diff --git a/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp b/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp index ba7db6e0f0d..99dcb66a083 100644 --- a/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -211,7 +211,7 @@ NS_IMETHODIMP nsHTMLSelectableAccessible::GetSelectedChildren(nsIArray **_retval if (!selectedAccessibles) return NS_ERROR_OUT_OF_MEMORY; - nsCOMPtr context(GetPresContext()); + nsPresContext *context = GetPresContext(); if (!context) return NS_ERROR_FAILURE; @@ -237,7 +237,7 @@ NS_IMETHODIMP nsHTMLSelectableAccessible::RefSelection(PRInt32 aIndex, nsIAccess if (!accService) return NS_ERROR_FAILURE; - nsCOMPtr context(GetPresContext()); + nsPresContext *context = GetPresContext(); if (!context) return NS_ERROR_FAILURE; @@ -1129,7 +1129,7 @@ NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetNumActions(PRUint8 *aNumActions NS_IMETHODIMP nsHTMLComboboxButtonAccessible::DoAction(PRUint8 aIndex) { nsIFrame* frame = nsAccessible::GetBoundsFrame(); - nsCOMPtr context(GetPresContext()); + nsPresContext *context = GetPresContext(); if (!frame || !context) return NS_ERROR_FAILURE; @@ -1189,7 +1189,7 @@ void nsHTMLComboboxButtonAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** a // bounding frame is the ComboboxControlFrame nsIFrame *frame = nsAccessible::GetBoundsFrame(); *aBoundingFrame = frame; - nsCOMPtr context(GetPresContext()); + nsPresContext *context = GetPresContext(); if (!frame || !context) return; diff --git a/mozilla/accessible/src/html/nsHTMLTextAccessible.cpp b/mozilla/accessible/src/html/nsHTMLTextAccessible.cpp index 23d4ef34277..4543698b67e 100644 --- a/mozilla/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/mozilla/accessible/src/html/nsHTMLTextAccessible.cpp @@ -82,8 +82,6 @@ NS_IMETHODIMP nsHTMLTextAccessible::GetState(PRUint32 *aState) return NS_ERROR_FAILURE; } - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); nsCOMPtr content(do_QueryInterface(mDOMNode)); nsIFrame *frame = nsnull; // The root frame and all text frames in the document share the same @@ -91,7 +89,8 @@ NS_IMETHODIMP nsHTMLTextAccessible::GetState(PRUint32 *aState) shell->GetRootFrame(&frame); if (frame) { nsCOMPtr selCon; - frame->GetSelectionController(context, getter_AddRefs(selCon)); + frame->GetSelectionController(shell->GetPresContext(), + getter_AddRefs(selCon)); if (selCon) { nsCOMPtr domSel; selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)); diff --git a/mozilla/accessible/src/msaa/nsTextAccessibleWrap.cpp b/mozilla/accessible/src/msaa/nsTextAccessibleWrap.cpp index 0073ca76d00..45bf079c07d 100755 --- a/mozilla/accessible/src/msaa/nsTextAccessibleWrap.cpp +++ b/mozilla/accessible/src/msaa/nsTextAccessibleWrap.cpp @@ -173,8 +173,7 @@ STDMETHODIMP nsTextAccessibleWrap::scrollToSubstring( return E_FAIL; // This accessible has been shut down } - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); nsCOMPtr scrollToRange = do_CreateInstance(kRangeCID); nsCOMPtr selCon; frame->GetSelectionController(presContext, getter_AddRefs(selCon)); @@ -227,8 +226,7 @@ nsresult nsTextAccessibleWrap::GetCharacterExtents(PRInt32 aStartOffset, PRInt32 nsCOMPtr presShell(GetPresShell()); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); float t2p = presContext->TwipsToPixels(); diff --git a/mozilla/content/base/src/nsContentSink.cpp b/mozilla/content/base/src/nsContentSink.cpp index 5adb4ed84d2..58d6c840379 100644 --- a/mozilla/content/base/src/nsContentSink.cpp +++ b/mozilla/content/base/src/nsContentSink.cpp @@ -947,9 +947,7 @@ nsContentSink::StartLayout(PRBool aIsFrameset) shell->BeginObservingDocument(); // Resize-reflow this time - nsCOMPtr cx; - shell->GetPresContext(getter_AddRefs(cx)); - nsRect r = cx->GetVisibleArea(); + nsRect r = shell->GetPresContext()->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 f087808937d..f3ce22e5bba 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -1996,8 +1996,7 @@ nsDocument::EndLoad() nsIPresShell *shell = ancestor_doc->GetShellAt(0); if (shell) { - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); + nsCOMPtr context = shell->GetPresContext(); if (context) { // The event argument to HandleDOMEvent() is inout, and @@ -2802,9 +2801,8 @@ nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView) mPresShells.ElementAt(0)); NS_ENSURE_TRUE(shell, NS_OK); - nsCOMPtr ctx; - nsresult rv = shell->GetPresContext(getter_AddRefs(ctx)); - NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && ctx, rv); + nsPresContext *ctx = shell->GetPresContext(); + NS_ENSURE_TRUE(ctx, NS_OK); nsCOMPtr container = ctx->GetContainer(); NS_ENSURE_TRUE(container, NS_OK); @@ -2847,11 +2845,7 @@ nsDocument::SetTitle(const nsAString& aTitle) nsCOMPtr shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]); - nsCOMPtr context; - nsresult rv = shell->GetPresContext(getter_AddRefs(context)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr container = context->GetContainer(); + nsCOMPtr container = shell->GetPresContext()->GetContainer(); if (!container) continue; @@ -2859,7 +2853,7 @@ nsDocument::SetTitle(const nsAString& aTitle) if (!docShellWin) continue; - rv = docShellWin->SetTitle(PromiseFlatString(aTitle).get()); + nsresult rv = docShellWin->SetTitle(PromiseFlatString(aTitle).get()); NS_ENSURE_SUCCESS(rv, rv); } @@ -3004,8 +2998,7 @@ nsDocument::GetDir(nsAString& aDirection) { nsCOMPtr shell = (nsIPresShell*)mPresShells.SafeElementAt(0); if (shell) { - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = shell->GetPresContext(); if (context) { PRUint32 options = context->GetBidi(); for (const DirTable* elt = dirAttributes; elt->mName; elt++) { @@ -3035,8 +3028,7 @@ nsDocument::SetDir(const nsAString& aDirection) return NS_OK; } - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = shell->GetPresContext(); NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED); PRUint32 options = context->GetBidi(); @@ -3937,11 +3929,9 @@ nsDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval) if (!shell) return NS_ERROR_FAILURE; - // Retrieve the context - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); + nsCOMPtr context = shell->GetPresContext(); - return presContext->EventStateManager()-> + return context->EventStateManager()-> DispatchNewEvent(NS_STATIC_CAST(nsIDOMDocument*, this), aEvent, _retval); } @@ -3999,14 +3989,15 @@ nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn) NS_ENSURE_ARG_POINTER(aReturn); *aReturn = nsnull; - // Obtain a presentation context + // Obtain a presentation shell nsIPresShell *shell = GetShellAt(0); - nsCOMPtr presContext; + + nsPresContext *presContext = nsnull; if (shell) { // Retrieve the context - shell->GetPresContext(getter_AddRefs(presContext)); + presContext = shell->GetPresContext(); } nsCOMPtr manager; diff --git a/mozilla/content/base/src/nsImageLoadingContent.cpp b/mozilla/content/base/src/nsImageLoadingContent.cpp index 64792799602..4278baff9ec 100644 --- a/mozilla/content/base/src/nsImageLoadingContent.cpp +++ b/mozilla/content/base/src/nsImageLoadingContent.cpp @@ -687,8 +687,7 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType) nsIPresShell *shell = document->GetShellAt(0); NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = shell->GetPresContext(); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); nsCOMPtr ourContent = do_QueryInterface(this); diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 9808a83841c..43ff27ae739 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -1914,13 +1914,11 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval) if (!shell) { return NS_OK; } - - // Retrieve the context - nsCOMPtr aPresContext; - shell->GetPresContext(getter_AddRefs(aPresContext)); - return aPresContext->EventStateManager()->DispatchNewEvent(mTarget, aEvent, - _retval); + nsCOMPtr context = shell->GetPresContext(); + + return context->EventStateManager()-> + DispatchNewEvent(mTarget, aEvent, _retval); } // nsIDOM3EventTarget interface diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 073e95072e0..a44ea6b4eeb 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -598,8 +598,8 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (doc) { nsIPresShell *shell = doc->GetShellAt(0); if (shell) { - nsCOMPtr oldPresContext; - shell->GetPresContext(getter_AddRefs(oldPresContext)); + nsCOMPtr oldPresContext = + shell->GetPresContext(); nsCOMPtr esm; esm = oldPresContext->EventStateManager(); @@ -732,8 +732,8 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (doc) { nsIPresShell *shell = doc->GetShellAt(0); if (shell) { - nsCOMPtr oldPresContext; - shell->GetPresContext(getter_AddRefs(oldPresContext)); + nsCOMPtr oldPresContext = + shell->GetPresContext(); nsCOMPtr esm = oldPresContext->EventStateManager(); @@ -822,8 +822,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (shell) { if (focusedElement) { nsCOMPtr focusContent = do_QueryInterface(focusedElement); - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); + nsCOMPtr context = shell->GetPresContext(); focusContent->SetFocus(context); } @@ -887,8 +886,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (gLastFocusedContent) { nsIPresShell *shell = gLastFocusedDocument->GetShellAt(0); if (shell) { - nsCOMPtr oldPresContext; - shell->GetPresContext(getter_AddRefs(oldPresContext)); + nsCOMPtr oldPresContext = shell->GetPresContext(); nsCOMPtr focusedElement; if (focusController) @@ -1091,8 +1089,7 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext, continue; } - subPS->GetPresContext(getter_AddRefs(subPC)); - NS_ASSERTION(subPC, "PresShell without PresContext"); + nsPresContext *subPC = subPS->GetPresContext(); nsEventStateManager* esm = NS_STATIC_CAST(nsEventStateManager *, subPC->EventStateManager()); @@ -1122,12 +1119,11 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext, docShell->GetChildOffset(&myOffset); nsCOMPtr parentPS; - nsCOMPtr parentPC; parentDS->GetPresShell(getter_AddRefs(parentPS)); NS_ASSERTION(parentPS, "Our PresShell exists but the parent's does not?"); - parentPS->GetPresContext(getter_AddRefs(parentPC)); + nsPresContext *parentPC = parentPS->GetPresContext(); NS_ASSERTION(parentPC, "PresShell without PresContext"); nsEventStateManager* esm = @@ -1575,8 +1571,7 @@ nsEventStateManager::ChangeTextSize(PRInt32 change) nsIPresShell *presShell = doc->GetShellAt(0); if(!presShell) return NS_ERROR_FAILURE; - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if(!presContext) return NS_ERROR_FAILURE; nsCOMPtr pcContainer = presContext->GetContainer(); @@ -1826,7 +1821,7 @@ nsEventStateManager::GetParentScrollingView(nsInputEvent *aEvent, pPresShell->GetPrimaryFrameFor(frameContent, &frameFrame); if (!frameFrame) return NS_ERROR_FAILURE; - pPresShell->GetPresContext(&presCtxOuter); //addrefs + NS_IF_ADDREF(presCtxOuter = pPresShell->GetPresContext()); targetOuterFrame = frameFrame; return NS_OK; @@ -3297,9 +3292,7 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) nsIDocument *parent_doc = parentShell->GetDocument(); nsIContent *docContent = parent_doc->FindContentForSubDocument(mDocument); - nsCOMPtr parentPC; - parentShell->GetPresContext(getter_AddRefs(parentPC)); - + nsCOMPtr parentPC = parentShell->GetPresContext(); nsIEventStateManager *parentESM = parentPC->EventStateManager(); SetContentState(nsnull, NS_EVENT_STATE_FOCUS); @@ -3976,8 +3969,7 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext, if (shell) { kungFuDeathGrip = shell->GetViewManager(); - nsCOMPtr oldPresContext; - shell->GetPresContext(getter_AddRefs(oldPresContext)); + nsCOMPtr oldPresContext = shell->GetPresContext(); //fire blur nsEventStatus status = nsEventStatus_eIgnore; diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 1de8eccafe6..79437d43c21 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -598,9 +598,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent) } // Get the Presentation Context from the Shell - nsCOMPtr context; - presShell->GetPresContext(getter_AddRefs(context)); - + nsPresContext *context = presShell->GetPresContext(); if (!context) { return; } @@ -973,8 +971,7 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView, } // Get the presentation context - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if (!presContext) { return; } @@ -2368,21 +2365,20 @@ nsGenericHTMLElement::RestoreFormControlState(nsIHTMLContent* aContent, } // XXX This creates a dependency between content and frames -nsresult -nsGenericHTMLElement::GetPresContext(nsIHTMLContent* aContent, - nsPresContext** aPresContext) +nsPresContext* +nsGenericHTMLElement::GetPresContext() { // Get the document - nsIDocument* doc = aContent->GetDocument(); + nsIDocument* doc = GetDocument(); if (doc) { // Get presentation shell 0 nsIPresShell *presShell = doc->GetShellAt(0); if (presShell) { - return presShell->GetPresContext(aPresContext); + return presShell->GetPresContext(); } } - return NS_NOINTERFACE; + return nsnull; } // XXX check all mappings against ebina's usage @@ -3617,8 +3613,7 @@ nsGenericHTMLFrameElement::HandleChromeEvent(nsPresContext* aPresContext, void nsGenericHTMLElement::SetElementFocus(PRBool aDoFocus) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); if (!presContext) return; @@ -3702,8 +3697,7 @@ nsGenericHTMLElement::RegUnRegAccessKey(PRBool aDoReg) } // We have an access key, so get the ESM from the pres context. - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsPresContext *presContext = GetPresContext(); if (presContext) { nsIEventStateManager *esm = presContext->EventStateManager(); diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index 82bd7cd996f..3b0a9484718 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -624,12 +624,10 @@ public: nsIFormControl* aControl); /** - * Get the presentation context for a content node. - * @param aContent the content node - * @param aPresContext the presentation context [OUT] + * Get the presentation context for this content node. + * @return the presentation context */ - static nsresult GetPresContext(nsIHTMLContent* aContent, - nsPresContext** aPresContext); + NS_HIDDEN_(nsPresContext*) GetPresContext(); // Form Helper Routines /** diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 8247e1ba985..7b84444438f 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -334,9 +334,7 @@ nsHTMLBodyElement::Get##func_(nsAString& aColor) \ if (NS_CONTENT_ATTR_NOT_THERE == \ GetAttr(kNameSpaceID_None, nsHTMLAtoms::attr_, color)) { \ \ - nsCOMPtr presContext; \ - GetPresContext(this, getter_AddRefs(presContext)); \ - \ + nsPresContext *presContext = GetPresContext(); \ if (presContext) { \ attrColor = presContext->Default##default_(); \ NS_RGBToHex(attrColor, aColor); \ diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index 26c3d942ceb..d54c71adb26 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -203,8 +203,7 @@ nsHTMLButtonElement::Click() if (doc) { nsIPresShell *shell = doc->GetShellAt(0); if (shell) { - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); + nsCOMPtr context = shell->GetPresContext(); if (context) { nsEventStatus status = nsEventStatus_eIgnore; nsMouseEvent event(NS_MOUSE_LEFT_CLICK); diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index f885624e5d3..60fb9da2f54 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -564,8 +564,7 @@ nsHTMLFormElement::Submit() { // Send the submit event nsresult rv = NS_OK; - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); if (presContext) { if (mPendingSubmission) { // aha, we have a pending submission that was not flushed @@ -585,8 +584,7 @@ nsHTMLFormElement::Reset() { // Send the reset event nsresult rv = NS_OK; - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); if (presContext) { // Calling HandleDOMEvent() directly so that reset() will work even if // the frame does not exist. This does not have an effect right now, but @@ -1206,10 +1204,9 @@ nsHTMLFormElement::FlushPendingSubmission() } // - // preform the submission with the stored pending submission + // perform the submission with the stored pending submission // - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); SubmitSubmission(presContext, mPendingSubmission); // now delete the pending submission object diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 4e7e8928225..d7f06637c48 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -272,9 +272,7 @@ nsHTMLImageElement::GetXY() } // Get the Presentation Context from the Shell - nsCOMPtr context; - presShell->GetPresContext(getter_AddRefs(context)); - + nsPresContext *context = presShell->GetPresContext(); if (!context) { return point; } @@ -357,9 +355,7 @@ nsHTMLImageElement::GetWidthHeight() size.height -= margin.top + margin.bottom; size.width -= margin.left + margin.right; - nsCOMPtr context; - GetPresContext(this, getter_AddRefs(context)); - + nsPresContext *context = GetPresContext(); if (context) { float t2p; t2p = context->TwipsToPixels(); diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index aef0993ce2a..5ae1c3950b3 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -702,8 +702,7 @@ nsHTMLInputElement::SetValueInternal(const nsAString& aValue, } // If the frame owns the value, set the value in the frame if (frameOwnsValue) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue); return NS_OK; } @@ -979,8 +978,7 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked, PRBool aNotify) // nsIFrame* frame = GetPrimaryFrame(PR_FALSE); if (frame) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsPresContext *presContext = GetPresContext(); if (mType == NS_FORM_INPUT_CHECKBOX) { nsICheckboxControlFrame* checkboxFrame = nsnull; @@ -1015,10 +1013,9 @@ nsHTMLInputElement::FireOnChange() // // Since the value is changing, send out an onchange event (bug 23571) // - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore; nsEvent event(NS_FORM_CHANGE); + nsCOMPtr presContext = GetPresContext(); HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } @@ -1101,8 +1098,7 @@ nsHTMLInputElement::Select() // XXX Bug? We have to give the input focus before contents can be // selected - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); // 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 @@ -1200,12 +1196,11 @@ nsHTMLInputElement::Click() // Strong in case the event kills it nsCOMPtr doc = GetOwnerDoc(); - nsCOMPtr context; nsIPresShell *shell = doc->GetShellAt(0); if (shell) { - shell->GetPresContext(getter_AddRefs(context)); + nsCOMPtr context = shell->GetPresContext(); if (context) { nsEventStatus status = nsEventStatus_eIgnore; diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index 4083fb95708..721ca10ff52 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -551,9 +551,6 @@ nsHTMLScriptElement::ScriptAvailable(nsresult aResult, const nsAString& aScript) { if (!aIsInline && NS_FAILED(aResult)) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); - nsEventStatus status = nsEventStatus_eIgnore; nsScriptErrorEvent event(NS_SCRIPT_ERROR); @@ -568,8 +565,8 @@ nsHTMLScriptElement::ScriptAvailable(nsresult aResult, NS_ConvertUTF8toUCS2 fileName(spec); event.fileName = fileName.get(); - HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, - &status); + nsCOMPtr presContext = GetPresContext(); + HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } return NS_OK; @@ -587,11 +584,9 @@ nsHTMLScriptElement::ScriptEvaluated(nsresult aResult, { nsresult rv = NS_OK; if (!aIsInline) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); - nsEventStatus status = nsEventStatus_eIgnore; nsEvent event(NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR); + nsCOMPtr presContext = GetPresContext(); rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 771e3145e95..2b7ecd5d04d 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -537,9 +537,9 @@ nsHTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions, // get into the right state once it's created. nsISelectControlFrame* selectFrame = GetSelectFrame(); - nsCOMPtr presContext; + nsPresContext *presContext = nsnull; if (selectFrame) { - GetPresContext(this, getter_AddRefs(presContext)); + presContext = GetPresContext(); } // Actually select the options if the added options warrant it @@ -626,8 +626,7 @@ nsHTMLSelectElement::RemoveOptionsFromList(nsIContent* aOptions, // Tell the widget we removed the options nsISelectControlFrame* selectFrame = GetSelectFrame(); if (selectFrame) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsPresContext *presContext = GetPresContext(); for (int i = aListIndex; i < aListIndex + numRemoved; ++i) { selectFrame->RemoveOption(presContext, i); } @@ -1243,8 +1242,7 @@ nsHTMLSelectElement::SetOptionsSelectedByIndex(PRInt32 aStartIndex, nsISelectControlFrame *selectFrame = nsnull; PRBool did_get_frame = PR_FALSE; - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsPresContext *presContext = GetPresContext(); if (aIsSelected) { // Only select the first value if it's not multiple diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index a52747cc6e7..4d00fdcb595 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -276,8 +276,7 @@ nsHTMLTextAreaElement::Select() // selected // Just like SetFocus() but without the ScrollIntoView()! - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); + nsCOMPtr presContext = GetPresContext(); nsEventStatus status = nsEventStatus_eIgnore; nsGUIEvent event(NS_FORM_SELECTED); @@ -401,10 +400,8 @@ nsHTMLTextAreaElement::SetValueInternal(const nsAString& aValue, textControlFrame->OwnsValue(&frameOwnsValue); } if (frameOwnsValue) { - nsCOMPtr presContext; - GetPresContext(this, getter_AddRefs(presContext)); - - formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue); + formControlFrame->SetProperty(GetPresContext(), + nsHTMLAtoms::value, aValue); } else { if (mValue) { diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 48b7a9f64a3..60f2680de14 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1100,8 +1100,7 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode) } nsCOMPtr shell = (nsIPresShell*)mPresShells.SafeElementAt(0); if (shell) { - nsCOMPtr pc; - shell->GetPresContext(getter_AddRefs(pc)); + nsPresContext *pc = shell->GetPresContext(); if (pc) { pc->SetCompatibilityMode(mCompatMode); } @@ -2499,9 +2498,6 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, nsresult rv = aShell->GetPrimaryFrameFor(body, &frame); if (NS_SUCCEEDED(rv) && frame) { nsSize size; - nsCOMPtr presContext; - - aShell->GetPresContext(getter_AddRefs(presContext)); nsIView* view = frame->GetView(); // If we have a view check if it's scrollable. If not, @@ -2524,10 +2520,8 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, } // Convert from twips to pixels - nsCOMPtr context; - rv = aShell->GetPresContext(getter_AddRefs(context)); - - if (NS_SUCCEEDED(rv)) { + nsPresContext *context = aShell->GetPresContext(); + if (context) { float scale; scale = context->TwipsToPixels(); @@ -2795,9 +2789,7 @@ nsHTMLDocument::GetSelection(nsAString& aReturn) return NS_OK; } - nsCOMPtr cx; - - shell->GetPresContext(getter_AddRefs(cx)); + nsPresContext *cx = shell->GetPresContext(); NS_ENSURE_TRUE(cx, NS_OK); nsCOMPtr container = cx->GetContainer(); @@ -3548,8 +3540,7 @@ nsHTMLDocument::SetDesignMode(const nsAString & aDesignMode) nsCOMPtr shell = (nsIPresShell*)mPresShells.SafeElementAt(0); NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); - nsCOMPtr cx; - shell->GetPresContext(getter_AddRefs(cx)); + nsPresContext *cx = shell->GetPresContext(); NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE); nsCOMPtr container = cx->GetContainer(); diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index a7a582e7388..b3b7687647a 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -556,9 +556,7 @@ nsImageDocument::CheckOverflowing() return NS_OK; } - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); - + nsPresContext *context = shell->GetPresContext(); nsRect visibleArea = context->GetVisibleArea(); nsCOMPtr content = do_QueryInterface(mBodyContent); diff --git a/mozilla/content/html/document/src/nsMediaDocument.cpp b/mozilla/content/html/document/src/nsMediaDocument.cpp index cdd674fb6df..c23378527df 100644 --- a/mozilla/content/html/document/src/nsMediaDocument.cpp +++ b/mozilla/content/html/document/src/nsMediaDocument.cpp @@ -282,9 +282,7 @@ nsMediaDocument::StartLayout() shell->BeginObservingDocument(); // Initial-reflow this time. - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); - nsRect visibleArea = context->GetVisibleArea(); + nsRect visibleArea = shell->GetPresContext()->GetVisibleArea(); shell->InitialReflow(visibleArea.width, visibleArea.height); // Now trigger a refresh. diff --git a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp index 8dd7f635b28..af6f875d0f8 100644 --- a/mozilla/content/html/style/src/nsComputedDOMStyle.cpp +++ b/mozilla/content/html/style/src/nsComputedDOMStyle.cpp @@ -194,10 +194,7 @@ nsComputedDOMStyle::Init(nsIDOMElement *aElement, } } - nsCOMPtr presCtx; - - aPresShell->GetPresContext(getter_AddRefs(presCtx)); - + nsPresContext *presCtx = aPresShell->GetPresContext(); NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE); mT2P = presCtx->TwipsToPixels(); @@ -615,8 +612,7 @@ nsComputedDOMStyle::GetFontFamily(nsIFrame *aFrame, if (font) { nsCOMPtr presShell = do_QueryReferent(mPresShellWeak); NS_ASSERTION(presShell, "pres shell is required"); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); NS_ASSERTION(presContext, "pres context is required"); const nsString& fontName = font->mFont.name; @@ -2785,10 +2781,6 @@ nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide, nsIFrame* aFrame, // _not_ include the scrollbars. For fixed positioned frames, // the containing block is the viewport, which _does_ include // scrollbars. We have to do some extra work. - nsCOMPtr presShell = do_QueryReferent(mPresShellWeak); - NS_ASSERTION(presShell, "Must have a presshell!"); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); // the first child in the default frame list is what we want nsIFrame* scrollingChild = container->GetFirstChild(nsnull); nsCOMPtr scrollFrame = diff --git a/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp b/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp index e2be5d262e0..4ef9cf0629c 100644 --- a/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp +++ b/mozilla/content/html/style/src/nsInspectorCSSUtils.cpp @@ -163,8 +163,7 @@ nsInspectorCSSUtils::GetStyleContextForContent(nsIContent* aContent, if (parent) parentContext = GetStyleContextForContent(parent, nsnull, aPresShell); - nsCOMPtr presContext; - aPresShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = aPresShell->GetPresContext(); if (!presContext) return nsnull; diff --git a/mozilla/content/svg/content/src/nsSVGSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGSVGElement.cpp index b531cd53cfc..7dd50620124 100644 --- a/mozilla/content/svg/content/src/nsSVGSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGSVGElement.cpp @@ -358,8 +358,7 @@ nsSVGSVGElement::GetPixelUnitToMillimeterX(float *aPixelUnitToMillimeterX) if (!presShell) return NS_OK; // Get the Presentation Context from the Shell - nsCOMPtr context; - presShell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = presShell->GetPresContext(); if (!context) return NS_OK; *aPixelUnitToMillimeterX = context->ScaledPixelsToTwips() / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f); @@ -388,8 +387,7 @@ nsSVGSVGElement::GetScreenPixelToMillimeterX(float *aScreenPixelToMillimeterX) if (!presShell) return NS_OK; // Get the Presentation Context from the Shell - nsCOMPtr context; - presShell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = presShell->GetPresContext(); if (!context) return NS_OK; float TwipsPerPx; @@ -1192,8 +1190,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y) return; } - nsCOMPtr context; - presShell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = presShell->GetPresContext(); if (!context) { NS_ERROR("couldn't get prescontext"); return; diff --git a/mozilla/content/svg/content/src/nsSVGScriptElement.cpp b/mozilla/content/svg/content/src/nsSVGScriptElement.cpp index f21353d8dd6..c3d8aa9f803 100644 --- a/mozilla/content/svg/content/src/nsSVGScriptElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGScriptElement.cpp @@ -232,7 +232,7 @@ nsSVGScriptElement::ScriptAvailable(nsresult aResult, if (IsInDoc()) { nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0); if (presShell) - presShell->GetPresContext(getter_AddRefs(presContext)); + presContext = presShell->GetPresContext(); } nsEventStatus status = nsEventStatus_eIgnore; @@ -272,7 +272,7 @@ nsSVGScriptElement::ScriptEvaluated(nsresult aResult, if (IsInDoc()) { nsIPresShell *presShell = GetOwnerDoc()->GetShellAt(0); if (presShell) - presShell->GetPresContext(getter_AddRefs(presContext)); + presContext = presShell->GetPresContext(); } nsEventStatus status = nsEventStatus_eIgnore; diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 474deb6ea76..b28112c0f2c 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -2016,10 +2016,7 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue) } if (validElement) { - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); - - presContext->EventStateManager()-> + shell->GetPresContext()->EventStateManager()-> UnregisterAccessKey(this, aOldValue.First()); } } @@ -3716,12 +3713,9 @@ nsXULElement::Focus() nsIPresShell *shell = mDocument->GetShellAt(0); - // Retrieve the context - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); - // Set focus - SetFocus(presContext); + nsCOMPtr context = shell->GetPresContext(); + SetFocus(context); return NS_OK; } @@ -3739,12 +3733,9 @@ nsXULElement::Blur() nsIPresShell *shell = mDocument->GetShellAt(0); - // Retrieve the context - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); - // Set focus - RemoveFocus(presContext); + nsCOMPtr context = shell->GetPresContext(); + RemoveFocus(context); return NS_OK; } @@ -3760,11 +3751,12 @@ nsXULElement::Click() nsCOMPtr doc = mDocument; // Strong just in case if (doc) { PRUint32 numShells = doc->GetNumberOfShells(); + // strong ref to PresContext so events don't destroy it nsCOMPtr context; for (PRUint32 i = 0; i < numShells; ++i) { nsIPresShell *shell = doc->GetShellAt(i); - shell->GetPresContext(getter_AddRefs(context)); + context = shell->GetPresContext(); nsMouseEvent eventDown(NS_MOUSE_LEFT_BUTTON_DOWN), eventUp(NS_MOUSE_LEFT_BUTTON_UP), @@ -3801,7 +3793,7 @@ nsXULElement::DoCommand() for (PRUint32 i = 0; i < numShells; ++i) { nsIPresShell *shell = doc->GetShellAt(i); - shell->GetPresContext(getter_AddRefs(context)); + context = shell->GetPresContext(); nsEventStatus status = nsEventStatus_eIgnore; nsMouseEvent event(NS_XUL_COMMAND); @@ -4031,8 +4023,7 @@ nsXULElement::HideWindowChrome(PRBool aShouldHide) nsIFrame* frame = nsnull; shell->GetPrimaryFrameFor(content, &frame); - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = shell->GetPresContext(); if (frame && presContext) { nsIView* view = frame->GetClosestView(); diff --git a/mozilla/content/xul/content/src/nsXULPopupListener.cpp b/mozilla/content/xul/content/src/nsXULPopupListener.cpp index cfb189deaa9..0504b41d860 100644 --- a/mozilla/content/xul/content/src/nsXULPopupListener.cpp +++ b/mozilla/content/xul/content/src/nsXULPopupListener.cpp @@ -329,7 +329,6 @@ XULPopupListenerImpl::FireFocusOnTargetContent(nsIDOMNode* aTargetNode) rv = aTargetNode->GetOwnerDocument(getter_AddRefs(domDoc)); if(NS_SUCCEEDED(rv) && domDoc) { - nsCOMPtr context; nsCOMPtr tempdoc = do_QueryInterface(domDoc); // Get nsIDOMElement for targetNode @@ -337,7 +336,8 @@ XULPopupListenerImpl::FireFocusOnTargetContent(nsIDOMNode* aTargetNode) if (!shell) return NS_ERROR_FAILURE; - shell->GetPresContext(getter_AddRefs(context)); + // strong reference to keep this from going away between events + nsCOMPtr context = shell->GetPresContext(); nsCOMPtr content = do_QueryInterface(aTargetNode); nsIFrame* targetFrame; diff --git a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp index e826cfb1762..3fcb9ba92fe 100644 --- a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -319,8 +319,6 @@ nsXULCommandDispatcher::RemoveCommandUpdater(nsIDOMElement* aElement) NS_IMETHODIMP nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName) { - nsresult rv; - EnsureFocusController(); NS_ENSURE_TRUE(mFocusController, NS_ERROR_FAILURE); @@ -328,7 +326,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName) nsCOMPtr element; mFocusController->GetFocusedElement(getter_AddRefs(element)); if (element) { - rv = element->GetAttribute(NS_LITERAL_STRING("id"), id); + nsresult rv = element->GetAttribute(NS_LITERAL_STRING("id"), id); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get element's id"); if (NS_FAILED(rv)) return rv; } @@ -377,9 +375,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName) nsIPresShell *shell = document->GetShellAt(i); // Retrieve the context in which our DOM event will fire. - nsCOMPtr context; - rv = shell->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(rv)) return rv; + nsCOMPtr context = shell->GetPresContext(); // Handle the DOM event nsEventStatus status = nsEventStatus_eIgnore; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 881d4eacb1c..0e34876f649 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1061,8 +1061,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster, nsCOMPtr shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[j]); - nsCOMPtr aPresContext; - shell->GetPresContext(getter_AddRefs(aPresContext)); + nsCOMPtr aPresContext = shell->GetPresContext(); // Handle the DOM event nsEventStatus status = nsEventStatus_eIgnore; @@ -1610,16 +1609,10 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth, } // Convert from twips to pixels - nsCOMPtr context; - result = aShell->GetPresContext(getter_AddRefs(context)); + float scale = aShell->GetPresContext()->TwipsToPixels(); - if (NS_SUCCEEDED(result)) { - float scale; - scale = context->TwipsToPixels(); - - *aWidth = NSTwipsToIntPixels(size.width, scale); - *aHeight = NSTwipsToIntPixels(size.height, scale); - } + *aWidth = NSTwipsToIntPixels(size.width, scale); + *aHeight = NSTwipsToIntPixels(size.height, scale); } else { *aWidth = 0; @@ -2121,8 +2114,7 @@ nsXULDocument::StartLayout(void) nsIPresShell *shell = GetShellAt(i); // Resize-reflow this time - nsCOMPtr cx; - shell->GetPresContext(getter_AddRefs(cx)); + nsPresContext *cx = shell->GetPresContext(); NS_ASSERTION(cx != nsnull, "no pres context"); if (! cx) return NS_ERROR_UNEXPECTED; diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 4b67484899a..b3b43bb5543 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -4938,8 +4938,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, } // Get the computed -moz-binding directly from the style context - nsCOMPtr pctx; - shell->GetPresContext(getter_AddRefs(pctx)); + nsPresContext *pctx = shell->GetPresContext(); NS_ENSURE_TRUE(pctx, NS_ERROR_UNEXPECTED); nsRefPtr sc = pctx->StyleSet()->ResolveStyleFor(content, diff --git a/mozilla/dom/src/base/nsFocusController.cpp b/mozilla/dom/src/base/nsFocusController.cpp index 26b42f823cc..32236031274 100644 --- a/mozilla/dom/src/base/nsFocusController.cpp +++ b/mozilla/dom/src/base/nsFocusController.cpp @@ -264,8 +264,7 @@ nsFocusController::MoveFocus(PRBool aForward, nsIDOMElement* aElt) return NS_OK; // Retrieve the context - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); + nsCOMPtr presContext = shell->GetPresContext(); // Make this ESM shift the focus per our instructions. presContext->EventStateManager()->ShiftFocus(aForward, content); diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 4590fc73a61..b882084cbdf 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -2990,8 +2990,7 @@ GlobalWindowImpl::CheckForAbusePoint() nsCOMPtr presShell; mDocShell->GetPresShell(getter_AddRefs(presShell)); if (presShell) { - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if (presContext) presContext->EventStateManager()->GetCurrentEvent(¤tEvent); } @@ -4073,15 +4072,14 @@ GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent, PRBool* _retval) { nsCOMPtr doc(do_QueryInterface(mDocument)); if (doc) { - // Obtain a presentation context + // Obtain a presentation shell nsIPresShell *shell = doc->GetShellAt(0); if (!shell) { return NS_OK; } // Retrieve the context - nsCOMPtr aPresContext; - shell->GetPresContext(getter_AddRefs(aPresContext)); + nsCOMPtr aPresContext = shell->GetPresContext(); aPresContext->EventStateManager()-> DispatchNewEvent(NS_STATIC_CAST(nsIScriptGlobalObject*, this), aEvent, _retval); diff --git a/mozilla/dom/src/base/nsGlobalWindowCommands.cpp b/mozilla/dom/src/base/nsGlobalWindowCommands.cpp index 80c81d732fa..ae4235fe0a5 100644 --- a/mozilla/dom/src/base/nsGlobalWindowCommands.cpp +++ b/mozilla/dom/src/base/nsGlobalWindowCommands.cpp @@ -235,8 +235,7 @@ nsSelectionCommandsBase::GetEventStateManagerForWindow(nsIDOMWindow *aWindow, GetPresShellFromWindow(aWindow, getter_AddRefs(presShell)); if (presShell) { - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if (presContext) { NS_ADDREF(*aEventStateManager = presContext->EventStateManager()); return NS_OK; diff --git a/mozilla/dom/src/base/nsWindowRoot.cpp b/mozilla/dom/src/base/nsWindowRoot.cpp index 3248f0d810c..a0904d2ec91 100644 --- a/mozilla/dom/src/base/nsWindowRoot.cpp +++ b/mozilla/dom/src/base/nsWindowRoot.cpp @@ -102,8 +102,7 @@ nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, PRBool *_retval) nsIPresShell *shell = doc->GetShellAt(0); // Retrieve the context - nsCOMPtr aPresContext; - shell->GetPresContext(getter_AddRefs(aPresContext)); + nsCOMPtr aPresContext = shell->GetPresContext(); return aPresContext->EventStateManager()-> DispatchNewEvent(NS_STATIC_CAST(nsIDOMEventReceiver*, this), diff --git a/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp b/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp index 8064ccec7f1..b1d990a881a 100644 --- a/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerDocumentCommands.cpp @@ -80,11 +80,7 @@ GetPresContextFromEditor(nsIEditor *aEditor, nsPresContext **aResult) nsCOMPtr presShell = do_QueryInterface(selCon); if (!presShell) return NS_ERROR_FAILURE; - nsCOMPtr presContext; - rv = presShell->GetPresContext(getter_AddRefs(presContext)); - if (NS_FAILED(rv)) return rv; - *aResult = presContext; - NS_IF_ADDREF(*aResult); + NS_IF_ADDREF(*aResult = presShell->GetPresContext()); return NS_OK; } diff --git a/mozilla/editor/composer/src/nsEditingSession.cpp b/mozilla/editor/composer/src/nsEditingSession.cpp index fd640ca6200..842c921d0b3 100644 --- a/mozilla/editor/composer/src/nsEditingSession.cpp +++ b/mozilla/editor/composer/src/nsEditingSession.cpp @@ -395,9 +395,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow) if (!presShell) return NS_ERROR_FAILURE; // Disable animation of images in this document: - nsCOMPtr presContext; - rv = presShell->GetPresContext(getter_AddRefs(presContext)); - if (NS_FAILED(rv)) return rv; + nsPresContext *presContext = presShell->GetPresContext(); if (!presContext) return NS_ERROR_FAILURE; presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index e2f03fa5b60..82e3f1d7120 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -267,8 +267,7 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc, mHTMLCSSUtils->Init(this); // disable links - nsCOMPtr context; - aPresShell->GetPresContext(getter_AddRefs(context)); + nsPresContext *context = aPresShell->GetPresContext(); if (!context) return NS_ERROR_NULL_POINTER; if (!(mFlags & eEditorPlaintextMask)) context->SetLinkHandler(0); @@ -5951,11 +5950,7 @@ nsHTMLEditor::GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 & nsIFrame *frame = 0; // not ref-counted ps->GetPrimaryFrameFor(content, &frame); - float t2p; - nsCOMPtr pcontext; - ps->GetPresContext(getter_AddRefs(pcontext)); - t2p = pcontext->TwipsToPixels(); - + float t2p = ps->GetPresContext()->TwipsToPixels(); if (nsHTMLEditUtils::IsHR(aElement)) { frame = frame->GetNextSibling(); diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index 7b4e54b24d9..b9473cd0289 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -971,8 +971,7 @@ IsTargetFocused(nsIDOMEventTarget* aTarget) if (!shell) return PR_FALSE; - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = shell->GetPresContext(); if (!presContext) return PR_FALSE; diff --git a/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp b/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp index 774e0eee2ea..b867426ab3c 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp +++ b/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp @@ -60,10 +60,7 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsIDOMNode *aSelNode, if (!shell) return NS_ERROR_NULL_POINTER; - nsCOMPtr context; - res = shell->GetPresContext(getter_AddRefs(context)); - if (NS_FAILED(res)) - return res; + nsPresContext *context = shell->GetPresContext(); if (!context) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp b/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp index 8a62f35274e..eb4edc31e60 100644 --- a/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp +++ b/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp @@ -390,9 +390,7 @@ FocusElementButNotDocument(nsIDocument* aDocument, nsIContent* aContent) focusController->SetFocusedElement(newFocusedElement); nsIPresShell* presShell = aDocument->GetShellAt(0); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - nsIEventStateManager* esm = presContext->EventStateManager(); + nsIEventStateManager* esm = presShell->GetPresContext()->EventStateManager(); // Temporarily set esm::mCurrentFocus so that esm::GetContentState() tells // layout system to show focus on this element. @@ -457,8 +455,7 @@ void nsWebBrowserFind::SetSelectionAndScroll(nsIDOMWindow* aWindow, FocusElementButNotDocument(doc, content); } else { - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsCOMPtr presContext = presShell->GetPresContext(); PRBool isSelectionWithFocus; presContext->EventStateManager()-> MoveFocusToCaret(PR_TRUE, &isSelectionWithFocus); @@ -834,9 +831,7 @@ nsWebBrowserFind::GetFrameSelection(nsIDOMWindow* aWindow, // text input controls have their independent selection controllers // that we must use when they have focus. - - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); nsIFrame *frame = nsnull; presContext->EventStateManager()->GetFocusedFrame(&frame); diff --git a/mozilla/extensions/inspector/base/src/inFlasher.cpp b/mozilla/extensions/inspector/base/src/inFlasher.cpp index e1469e9ec86..c0d941a4734 100644 --- a/mozilla/extensions/inspector/base/src/inFlasher.cpp +++ b/mozilla/extensions/inspector/base/src/inFlasher.cpp @@ -167,11 +167,9 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement) if (!window) return NS_OK; nsCOMPtr presShell = inLayoutUtils::GetPresShellFor(window); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); - float p2t; - p2t = presContext->PixelsToTwips(); + float p2t = presContext->PixelsToTwips(); PRBool isFirstFrame = PR_TRUE; nsCOMPtr rcontext; diff --git a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp index c88b25e59fc..8e9d766de31 100644 --- a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp +++ b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp @@ -125,11 +125,7 @@ inLayoutUtils::GetEventStateManagerFor(nsIDOMElement *aElement) nsIPresShell *shell = doc->GetShellAt(0); NS_ASSERTION(shell, "No pres shell"); - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); - NS_ASSERTION(presContext, "No pres context"); - - return presContext->EventStateManager(); + return shell->GetPresContext()->EventStateManager(); } nsPoint @@ -171,8 +167,7 @@ inLayoutUtils::GetScreenOrigin(nsIDOMElement* aElement) // Flush all pending notifications so that our frames are uptodate doc->FlushPendingNotifications(Flush_Layout); - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if (presContext) { nsIFrame* frame = nsnull; diff --git a/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp b/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp index c60d629273f..629ed30e3a2 100644 --- a/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/mozilla/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -429,12 +429,9 @@ DumpFramesRecur(nsIDocShell* aDocShell, FILE* out) nsIFrame* root; shell->GetRootFrame(&root); if (root) { - nsCOMPtr presContext; - shell->GetPresContext(getter_AddRefs(presContext)); - nsIFrameDebug* fdbg; if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) { - fdbg->List(presContext, out, 0); + fdbg->List(shell->GetPresContext(), out, 0); } } } diff --git a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp index 261715f47d0..8064f35f72c 100644 --- a/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp +++ b/mozilla/extensions/layout-debug/src/nsRegressionTester.cpp @@ -124,10 +124,7 @@ nsRegressionTester::DumpFrameModel(nsIDOMWindow *aWindowToDump, nsILocalFile *aD if (NS_FAILED(rv)) return rv; } - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - - fdbg->DumpRegressionData(presContext, fp, 0, dumpStyle); + fdbg->DumpRegressionData(presShell->GetPresContext(), fp, 0, dumpStyle); if (fp != stdout) fclose(fp); diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 6b3aab2fa9e..8687028968f 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -923,10 +923,9 @@ nsTypeAheadFind::HandleChar(PRUnichar aChar) // If not, make sure the selection is in sync with the focus, so we can // start our search from there. nsCOMPtr focusedContent; - nsCOMPtr presContext; nsCOMPtr presShell(do_QueryReferent(mFocusedWeakShell)); NS_ENSURE_TRUE(presShell, NS_OK); - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); NS_ENSURE_TRUE(presContext, NS_OK); nsIEventStateManager *esm = presContext->EventStateManager(); @@ -1209,9 +1208,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, } } - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - + nsCOMPtr presContext = presShell->GetPresContext(); if (!presContext) { return NS_ERROR_FAILURE; } @@ -1715,8 +1712,7 @@ nsTypeAheadFind::FindNext(PRBool aFindBackwards, nsISupportsInterfacePointer *aC nsCOMPtr typeAheadPresShell(do_QueryReferent(mFocusedWeakShell)); NS_ENSURE_TRUE(typeAheadPresShell, NS_OK); - nsCOMPtr presContext; - typeAheadPresShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = typeAheadPresShell->GetPresContext(); NS_ENSURE_TRUE(presContext, NS_OK); nsCOMPtr container = presContext->GetContainer(); @@ -2488,9 +2484,7 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, return NS_OK; } - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - if (presContext->Type() == nsPresContext::eContext_PrintPreview) { + if (presShell->GetPresContext()->Type() == nsPresContext::eContext_PrintPreview) { // Typeaheadfind is not designed to work in print preview. // You can't navigate through the links there. if (lastShell != presShell) { @@ -2514,8 +2508,7 @@ nsTypeAheadFind::GetSelection(nsIPresShell *aPresShell, // if aCurrentNode is nsnull, get selection for document *aDOMSel = nsnull; - nsCOMPtr presContext; - aPresShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = aPresShell->GetPresContext(); nsIFrame *frame = nsnull; aPresShell->GetRootFrame(&frame); @@ -2715,8 +2708,7 @@ nsTypeAheadFind::DisplayStatus(PRBool aSuccess, nsIContent *aFocusedContent, return; } - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = presShell->GetPresContext(); if (!presContext) { return; } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 82561cdd275..db6aa76b21a 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -595,10 +595,7 @@ NS_IMETHODIMP mozXMLTerminal::ScreenSize(PRInt32* rows, PRInt32* cols, return NS_ERROR_FAILURE; // Get presentation context - nsCOMPtr presContext; - result = presShell->GetPresContext( getter_AddRefs(presContext) ); - if (NS_FAILED(result)) - return result; + nsPresContext *presContext = presShell->GetPresContext(); // Get the default fixed pitch font const nsFont* defaultFixedFont = diff --git a/mozilla/gfx/src/gtk/nsNativeThemeGTK.cpp b/mozilla/gfx/src/gtk/nsNativeThemeGTK.cpp index 80a0cae152f..c041f72b622 100644 --- a/mozilla/gfx/src/gtk/nsNativeThemeGTK.cpp +++ b/mozilla/gfx/src/gtk/nsNativeThemeGTK.cpp @@ -155,10 +155,8 @@ static PRInt32 GetContentState(nsIFrame* aFrame) if (!shell) return 0; - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); PRInt32 flags = 0; - context->EventStateManager()->GetContentState(aFrame->GetContent(), flags); + shell->GetPresContext()->EventStateManager()->GetContentState(aFrame->GetContent(), flags); return flags; } diff --git a/mozilla/gfx/src/shared/nsNativeTheme.cpp b/mozilla/gfx/src/shared/nsNativeTheme.cpp index 113e2ba6f2e..16df89f5f51 100644 --- a/mozilla/gfx/src/shared/nsNativeTheme.cpp +++ b/mozilla/gfx/src/shared/nsNativeTheme.cpp @@ -105,10 +105,8 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType) if (!shell) return 0; - nsCOMPtr context; - shell->GetPresContext(getter_AddRefs(context)); PRInt32 flags = 0; - context->EventStateManager()->GetContentState(aFrame->GetContent(), flags); + shell->GetPresContext()->EventStateManager()->GetContentState(aFrame->GetContent(), flags); if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) { if (IsFocused(aFrame)) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 0967e4c4312..67d95f253b0 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -7754,12 +7754,9 @@ nsCSSFrameConstructor::IsValidSibling(nsIPresShell& aPresShell, (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == aSiblingDisplay)) { // if we haven't already, construct a style context to find the display type of aContent if (UNSET_DISPLAY == aDisplay) { - nsCOMPtr context; - aPresShell.GetPresContext(getter_AddRefs(context)); - - nsIFrame* parent = aSibling.GetParent(); nsRefPtr styleContext; - styleContext = ResolveStyleContext(context, parent, &aContent); + styleContext = ResolveStyleContext(aPresShell.GetPresContext(), + aSibling.GetParent(), &aContent); if (!styleContext) return PR_FALSE; const nsStyleDisplay* display = styleContext->GetStyleDisplay(); aDisplay = display->mDisplay; diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 02900399ba0..422b0ac35be 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -117,13 +117,9 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell) // get nsILookAndFeel from the pres context, which has one cached. nsILookAndFeel *lookAndFeel = nsnull; + nsPresContext *presContext = inPresShell->GetPresContext(); - nsCOMPtr presContext; - inPresShell->GetPresContext(getter_AddRefs(presContext)); - if (presContext) - lookAndFeel = presContext->LookAndFeel(); - if (lookAndFeel) - { + if (presContext && (lookAndFeel = presContext->LookAndFeel())) { PRInt32 tempInt; if (NS_SUCCEEDED(lookAndFeel->GetMetric(nsILookAndFeel::eMetric_SingleLineCaretWidth, tempInt))) mCaretPixelsWidth = (nscoord)tempInt; @@ -340,11 +336,8 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI return NS_ERROR_UNEXPECTED; // ramp up to make a rendering context for measuring text. // First, we get the pres context ... - nsCOMPtr presContext; - err = presShell->GetPresContext(getter_AddRefs(presContext)); - if (NS_FAILED(err)) - return err; - + nsPresContext *presContext = presShell->GetPresContext(); + // ... then tell it to make a rendering context nsCOMPtr rendContext; err = presContext->DeviceContext()-> @@ -562,9 +555,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset(nsIDOMNode* aNode, PRInt32 aOffset, n // NS_STYLE_DIRECTION_LTR : LTR or Default // NS_STYLE_DIRECTION_RTL // NS_STYLE_DIRECTION_INHERIT - nsCOMPtr presContext; - rv = presShell->GetPresContext(getter_AddRefs(presContext)); - + nsPresContext *presContext = presShell->GetPresContext(); if (presContext && presContext->BidiEnabled()) { presShell->GetCaretBidiLevel(&bidiLevel); @@ -761,16 +752,14 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy if (!presShell) return; - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - viewOffset.x = 0; viewOffset.y = 0; nsPoint withinViewOffset(0, 0); // get the offset of this frame from its parent view (walks up frame hierarchy) nsIView* theView = nsnull; - caretFrame->GetOffsetFromView(presContext, withinViewOffset, &theView); + caretFrame->GetOffsetFromView(presShell->GetPresContext(), + withinViewOffset, &theView); if (theView == nsnull) return; if (outRelativeView && coordType == eClosestViewCoordinates) @@ -953,9 +942,7 @@ void nsCaret::GetCaretRectAndInvert() nsCOMPtr presShell = do_QueryReferent(mPresShell); if (!presShell) return; - nsCOMPtr presContext; - if (NS_FAILED(presShell->GetPresContext(getter_AddRefs(presContext)))) - return; + nsPresContext *presContext = presShell->GetPresContext(); // if the view changed, or we don't have a rendering context, make one // because of drawing issues, always make a new RC at the moment. See bug 28068 diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index e285bf91de0..d565eedf6ad 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -332,8 +332,7 @@ nsFrameManager::Destroy() { NS_ASSERTION(mPresShell, "Frame manager already shut down."); - nsCOMPtr presContext; - mPresShell->GetPresContext(getter_AddRefs(presContext)); + nsPresContext *presContext = mPresShell->GetPresContext(); // Destroy the frame hierarchy. Don't destroy the property lists until after // we've destroyed the frame hierarchy because some frames may expect to be @@ -425,12 +424,10 @@ nsFrameManager::GetPrimaryFrameFor(nsIContent* aContent) // very fast in the embedded hash table. // This would almost completely remove the lookup penalty for things // like