diff --git a/mozilla/accessible/src/base/nsAccessibilityService.cpp b/mozilla/accessible/src/base/nsAccessibilityService.cpp index 174dbfeab5d..8e8ea7265ce 100644 --- a/mozilla/accessible/src/base/nsAccessibilityService.cpp +++ b/mozilla/accessible/src/base/nsAccessibilityService.cpp @@ -462,10 +462,8 @@ nsAccessibilityService::CreateHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsISu nsCOMPtr presContext(do_QueryInterface(aPresContext)); NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!"); - nsCOMPtr presShell; - presContext->GetShell(getter_AddRefs(presShell)); - - nsCOMPtr weakShell = do_GetWeakReference(presShell); + nsCOMPtr weakShell = + do_GetWeakReference(presContext->PresShell()); *_retval = new nsHTMLComboboxAccessible(aDOMNode, weakShell); if (! *_retval) @@ -531,10 +529,8 @@ nsAccessibilityService::CreateHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsISup nsCOMPtr presContext(do_QueryInterface(aPresContext)); NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!"); - nsCOMPtr presShell; - presContext->GetShell(getter_AddRefs(presShell)); - - nsCOMPtr weakShell = do_GetWeakReference(presShell); + nsCOMPtr weakShell = + do_GetWeakReference(presContext->PresShell()); *_retval = new nsHTMLSelectListAccessible(aDOMNode, weakShell); if (! *_retval) @@ -651,10 +647,8 @@ nsAccessibilityService::CreateHTMLSelectOptionAccessible(nsIDOMNode* aDOMNode, nsCOMPtr presContext(do_QueryInterface(aPresContext)); NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!"); - nsCOMPtr presShell; - presContext->GetShell(getter_AddRefs(presShell)); - - nsCOMPtr weakShell = do_GetWeakReference(presShell); + nsCOMPtr weakShell = + do_GetWeakReference(presContext->PresShell()); *_retval = new nsHTMLSelectOptionAccessible(aDOMNode, weakShell); if (! *_retval) diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 491301fed41..9da169dd6fb 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -1244,9 +1244,7 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings, // end observing the document BEFORE we do any new reflows if (cacheOldPres && !HasCachedPres()) { SetCacheOldPres(PR_TRUE); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->EndObservingDocument(); + mPresContext->PresShell()->EndObservingDocument(); } if (aWebProgressListener != nsnull) { @@ -4690,8 +4688,7 @@ static void RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aInde if (!aPresContext || !out) return; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsIFrame* frame; shell->GetRootFrame(&frame); diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 11d1061caa3..daab82714f1 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -1919,8 +1919,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // check if the prefs have been disabled for this shell // - if prefs are disabled then we use the document fonts anyway (yet another override) PRBool prefsEnabled = PR_TRUE; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mPresContext->GetPresShell(); if (shell) shell->ArePrefStyleRulesEnabled(prefsEnabled); if (!prefsEnabled) @@ -4332,10 +4331,8 @@ nsRuleNode::GetStyleData(nsStyleStructID aSID, // this works fine even if |this| is a rule node that has been // destroyed (leftover from a previous rule tree) but is somehow still // used. - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr set; - shell->GetStyleSet(getter_AddRefs(set)); + mPresContext->PresShell()->GetStyleSet(getter_AddRefs(set)); return set->GetDefaultStyleData()->GetStyleData(aSID); } diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 6ab0ffa917c..d1b7c86b2b3 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -1043,10 +1043,7 @@ nsSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested by the if (!context) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; + nsIPresShell *shell = context->GetPresShell(); if (!shell) return NS_ERROR_NULL_POINTER; @@ -1497,9 +1494,8 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA } nsCOMPtr caret; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result) || !shell) + nsIPresShell *shell = context->GetPresShell(); + if (!shell) return 0; result = shell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result) || !caret) @@ -2501,9 +2497,8 @@ void nsSelection::BidiLevelFromClick(nsIContent *aNode, PRUint32 aContentOffset) if (NS_FAILED(result) || !context) return; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result) || !shell) + nsIPresShell *shell = context->GetPresShell(); + if (!shell) return; nsIFrame* clickInFrame=nsnull; @@ -2764,8 +2759,7 @@ nsSelection::TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, if (NS_FAILED(result) || !presContext) return result?result:NS_ERROR_FAILURE; - nsCOMPtr presShell; - presContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = presContext->GetPresShell(); if (!presShell) return NS_ERROR_FAILURE; @@ -3082,11 +3076,7 @@ nsSelection::CommonPageMove(PRBool aForward, if (!context) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - - if (NS_FAILED(result)) - return result; + nsIPresShell *shell = context->GetPresShell(); if (!shell) return NS_ERROR_NULL_POINTER; @@ -5067,10 +5057,7 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange if ((NS_SUCCEEDED(result)) && iter && inneriter) { - nsCOMPtr presShell; - result = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_FAILED(result) && presShell) - presShell = 0; + nsIPresShell *presShell = aPresContext->GetPresShell(); #ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE nsCOMPtr genericiter = do_QueryInterface(iter); if (genericiter && presShell) @@ -6881,8 +6868,7 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell) if (!presContext) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - rv = presContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = presContext->GetPresShell(); mPresShellWeak = do_GetWeakReference(shell); // the presshell owns us, so no addref if (mPresShellWeak) NS_ADDREF(*aPresShell = shell); @@ -7719,10 +7705,9 @@ nsTypedSelection::SelectionLanguageChange(PRBool aLangRTL) mFrameSelection->GetPrevNextBidiLevels(context, focusContent, focusOffset, &frameBefore, &frameAfter, &levelBefore, &levelAfter); } - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result) || !shell) - return result?result:NS_ERROR_FAILURE; + nsIPresShell* shell = context->GetPresShell(); + if (!shell) + return NS_ERROR_FAILURE; if ((levelBefore & 1) == (levelAfter & 1)) { // if cursor is between two characters with the same orientation, changing the keyboard language diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index 788f7f1a550..7511921bc66 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -94,10 +94,8 @@ nsStyleContext::~nsStyleContext() nsIPresContext *presContext = mRuleNode->GetPresContext(); - nsCOMPtr shell; - presContext->GetShell(getter_AddRefs(shell)); nsCOMPtr set; - shell->GetStyleSet(getter_AddRefs(set)); + presContext->PresShell()->GetStyleSet(getter_AddRefs(set)); set->NotifyStyleContextDestroyed(presContext, this); if (mParent) { diff --git a/mozilla/content/base/src/nsStyleSet.cpp b/mozilla/content/base/src/nsStyleSet.cpp index 4f4f287bade..85de976e1a2 100644 --- a/mozilla/content/base/src/nsStyleSet.cpp +++ b/mozilla/content/base/src/nsStyleSet.cpp @@ -1608,9 +1608,8 @@ NS_IMETHODIMP StyleSetImpl::ConstructRootFrame(nsIPresContext* aPresContext, nsIContent* aDocElement, nsIFrame*& aFrameSubTree) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - return mFrameConstructor->ConstructRootFrame(shell, aPresContext, aDocElement, + return mFrameConstructor->ConstructRootFrame(aPresContext->PresShell(), + aPresContext, aDocElement, aFrameSubTree); } @@ -1693,9 +1692,8 @@ NS_IMETHODIMP StyleSetImpl::CantRenderReplacedElement(nsIPresContext* aPresContext, nsIFrame* aFrame) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - return mFrameConstructor->CantRenderReplacedElement(shell, aPresContext, aFrame); + return mFrameConstructor-> + CantRenderReplacedElement(aPresContext->PresShell(), aPresContext, aFrame); } NS_IMETHODIMP @@ -1704,9 +1702,9 @@ StyleSetImpl::CreateContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIFrame** aContinuingFrame) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - return mFrameConstructor->CreateContinuingFrame(shell, aPresContext, aFrame, aParentFrame, + return mFrameConstructor->CreateContinuingFrame(aPresContext->PresShell(), + aPresContext, aFrame, + aParentFrame, aContinuingFrame); } diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 05e8d738485..472145f5aac 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -347,9 +347,9 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMEventTarget** aTarget) } else { //Always want a target. Use document if nothing else. - nsCOMPtr doc; - nsCOMPtr presShell; - if (mPresContext && NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) { + nsIPresShell *presShell; + if (mPresContext && (presShell = mPresContext->GetPresShell())) { + nsCOMPtr doc; if (NS_SUCCEEDED(presShell->GetDocument(getter_AddRefs(doc))) && doc) { mTarget = do_QueryInterface(doc); if (mTarget) { @@ -729,9 +729,9 @@ NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX) } //My god, man, there *must* be a better way to do this. - nsCOMPtr presShell; nsIWidget* rootWidget = nsnull; - if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) { + nsIPresShell *presShell = mPresContext->GetPresShell(); + if (presShell) { nsIViewManager* vm = presShell->GetViewManager(); if (vm) { vm->GetWidget(&rootWidget); @@ -783,9 +783,9 @@ NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY) } //My god, man, there *must* be a better way to do this. - nsCOMPtr presShell; nsIWidget* rootWidget = nsnull; - if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) { + nsIPresShell *presShell = mPresContext->GetPresShell(); + if (presShell) { nsIViewManager* vm = presShell->GetViewManager(); if (vm) { vm->GetWidget(&rootWidget); @@ -1001,8 +1001,8 @@ nsresult nsDOMEvent::GetScrollInfo(nsIScrollableView** aScrollableView, mPresContext->GetPixelsToTwips(aP2T); mPresContext->GetTwipsToPixels(aT2P); - nsCOMPtr presShell; - if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) { + nsIPresShell *presShell = mPresContext->GetPresShell(); + if (presShell) { nsIViewManager* vm = presShell->GetViewManager(); if(vm) { return vm->GetRootScrollableView(aScrollableView); diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 7adea19d1bb..1db3a5fe1f0 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -1996,8 +1996,7 @@ nsEventListenerManager::FixContextMenuEvent(nsIPresContext* aPresContext, nsString empty; if (aEvent->message == NS_CONTEXTMENU_KEY) { - aPresContext->GetShell(getter_AddRefs(shell)); - shell->GetDocument(getter_AddRefs(doc)); + aPresContext->PresShell()->GetDocument(getter_AddRefs(doc)); if (doc) { nsCOMPtr privWindow = do_QueryInterface(doc->GetScriptGlobalObject()); if (privWindow) { diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 853047323ff..6cd856d9d39 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -576,8 +576,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, { // Hide the caret used in "browse with caret mode" if (mBrowseWithCaret && mPresContext) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) SetContentCaretVisible(presShell, mCurrentFocus, PR_FALSE); } @@ -902,11 +901,8 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext, if (!content) return; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - nsIFrame* frame = nsnull; - presShell->GetPrimaryFrameFor(content, &frame); + aPresContext->PresShell()->GetPrimaryFrameFor(content, &frame); if (frame) { const nsStyleVisibility* vis = frame->GetStyleVisibility(); @@ -1343,11 +1339,9 @@ nsEventStateManager::GetSelection(nsIFrame* inFrame, frameSel = do_QueryInterface(selCon); if (! frameSel) { - nsCOMPtr shell; - rv = inPresContext->GetShell(getter_AddRefs(shell)); - - if (NS_SUCCEEDED(rv) && shell) - rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); + nsIPresShell *shell = inPresContext->GetPresShell(); + if (shell) + shell->GetFrameSelection(getter_AddRefs(frameSel)); } *outSelection = frameSel.get(); @@ -1607,8 +1601,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext, // initialize nativeMsg field otherwise plugin code will crash when trying to access it mouseOutEvent.nativeMsg = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); // Otherwise, check for a focused content element nsCOMPtr focusContent; @@ -1734,14 +1727,7 @@ nsEventStateManager::GetParentScrollingView(nsMouseScrollEvent *aEvent, if (!aPresContext) return NS_ERROR_FAILURE; nsCOMPtr doc; - - { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - NS_ASSERTION(presShell, "No presshell in prescontext!"); - - presShell->GetDocument(getter_AddRefs(doc)); - } + aPresContext->PresShell()->GetDocument(getter_AddRefs(doc)); NS_ASSERTION(doc, "No document in prescontext!"); @@ -1900,11 +1886,10 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext, if (!targ) return NS_ERROR_FAILURE; } ret = CheckForAndDispatchClick(aPresContext, (nsMouseEvent*)aEvent, aStatus); - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr frameSel; - rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); + nsresult rv = shell->GetFrameSelection(getter_AddRefs(frameSel)); if (NS_SUCCEEDED(rv) && frameSel){ frameSel->SetMouseDownState(PR_FALSE); } @@ -2491,8 +2476,7 @@ nsEventStateManager::DispatchMouseEvent(nsIPresContext* aPresContext, NS_EVENT_FLAG_INIT, &status); // If frame refs were cleared, we need to re-resolve the frame if (mClearedFrameRefsDuringEvent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { shell->GetPrimaryFrameFor(aTargetContent, &aTargetFrame); } else { @@ -2907,8 +2891,7 @@ nsEventStateManager::CheckForAndDispatchClick(nsIPresContext* aPresContext, event.isAlt = aEvent->isAlt; event.isMeta = aEvent->isMeta; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsCOMPtr presShell = mPresContext->GetPresShell(); if (presShell) { nsCOMPtr mouseContent; GetEventTargetContent(aEvent, getter_AddRefs(mouseContent)); @@ -3079,8 +3062,7 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart) // If in content, navigate from last cursor position rather than last focus // If we're in UI, selection location will return null - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->PresShell(); // We might use the selection position, rather than mCurrentFocus, as our position to shift focus from PRInt32 itemType; @@ -3358,10 +3340,10 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent, if (!aFrame) { //No frame means we need to start with the root content again. - nsCOMPtr presShell; if (mPresContext) { nsIFrame* result = nsnull; - if (NS_SUCCEEDED(mPresContext->GetShell(getter_AddRefs(presShell))) && presShell) { + nsIPresShell *presShell = mPresContext->GetPresShell(); + if (presShell) { presShell->GetPrimaryFrameFor(aRootContent, &result); } @@ -3720,8 +3702,8 @@ nsEventStateManager::GetEventTarget(nsIFrame **aFrame) if (!mCurrentTarget && mCurrentTargetContent) { nsCOMPtr shell; if (mPresContext) { - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { shell->GetPrimaryFrameFor(mCurrentTargetContent, &mCurrentTarget); //This may be new frame that hasn't been through the ESM so we @@ -3733,8 +3715,7 @@ nsEventStateManager::GetEventTarget(nsIFrame **aFrame) } if (!mCurrentTarget) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { presShell->GetEventTargetFrame(&mCurrentTarget); @@ -3769,8 +3750,7 @@ nsEventStateManager::GetEventTargetContent(nsEvent* aEvent, *aContent = nsnull; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { presShell->GetEventTargetContent(aEvent, aContent); } @@ -4085,8 +4065,9 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent, PRBool aEnsureWindowHasFocus) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + // Keep a ref to presShell since dispatching the DOM event may cause + // the document to be destroyed. + nsCOMPtr presShell = aPresContext->PresShell(); nsCOMPtr previousFocus = mCurrentFocus; @@ -4521,11 +4502,8 @@ nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent, void nsEventStateManager::EnsureDocument(nsIPresContext* aPresContext) { - if (!mDocument) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - EnsureDocument(presShell); - } + if (!mDocument) + EnsureDocument(aPresContext->PresShell()); } void @@ -4539,9 +4517,8 @@ void nsEventStateManager::FlushPendingEvents(nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull != aPresContext, "nsnull ptr"); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - if (nsnull != shell) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { shell->FlushPendingNotifications(PR_FALSE); nsIViewManager* viewManager = shell->GetViewManager(); if (viewManager) { @@ -4585,9 +4562,9 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, if (!mDocument) return rv; - nsCOMPtr shell; + nsIPresShell *shell = nsnull; if (mPresContext) - rv = mPresContext->GetShell(getter_AddRefs(shell)); + shell = mPresContext->GetPresShell(); nsCOMPtr frameSelection; if (shell) @@ -4916,8 +4893,7 @@ nsEventStateManager::MoveCaretToFocus() selectionContent = parentContent; // Keep checking up chain of parents, focus may be in a link above us } - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mPresContext->GetPresShell(); if (shell) { // rangeDoc is a document interface we can create a range with nsCOMPtr rangeDoc(do_QueryInterface(mDocument)); @@ -5058,8 +5034,7 @@ nsEventStateManager::ResetBrowseWithCaret(PRBool *aBrowseWithCaret) mBrowseWithCaret = *aBrowseWithCaret; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); // Make caret visible or not, depending on what's appropriate if (presShell) { diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 9165f6628e6..f4de7c3b59c 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1547,10 +1547,11 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext, event.isAlt = keyEvent->isAlt; event.isMeta = keyEvent->isMeta; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { ret = presShell->HandleDOMEventWithTarget(this, &event, &status); + // presShell may no longer be alive, don't use it here + // unless you keep a reference. } } } @@ -3528,11 +3529,10 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsIHTMLMappedAttributes* // Resolve url to an absolute url // XXX this breaks if the HTML element has an xml:base // attribute (the xml:base will not be taken into account) - nsCOMPtr shell; - nsresult rv = aData->mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aData->mPresContext->GetPresShell(); + if (shell) { nsCOMPtr doc; - rv = shell->GetDocument(getter_AddRefs(doc)); + nsresult rv = shell->GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv) && doc) { nsCOMPtr docURL; nsHTMLValue baseHref; diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index 5cbb48c1384..e812e19131a 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -281,8 +281,7 @@ nsHTMLAnchorElement::SetFocus(nsIPresContext* aPresContext) mDocument->FlushPendingNotifications(); } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsIFrame* frame = nsnull; diff --git a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp index fd846ed2e0f..7d5ba3b9e8e 100644 --- a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp @@ -241,8 +241,7 @@ nsHTMLAreaElement::SetFocus(nsIPresContext* aPresContext) mDocument->FlushPendingNotifications(); } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsIFrame* frame = nsnull; diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index ba4b273dae0..bed4f2a5558 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -439,12 +439,8 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor) GetPresContext(this, getter_AddRefs(context)); if (context) { - nsCOMPtr shell; - rv = context->GetShell(getter_AddRefs(shell)); - NS_ENSURE_SUCCESS(rv, rv); - nsIFrame* frame; - rv = shell->GetPrimaryFrameFor(this, &frame); + rv = context->PresShell()->GetPrimaryFrameFor(this, &frame); NS_ENSURE_SUCCESS(rv, rv); if (frame) { @@ -523,8 +519,7 @@ void MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, nsRuleDat // When display if first asked for, go ahead and get our colors set up. nsHTMLValue value; - nsCOMPtr presShell; - aData->mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aData->mPresContext->GetPresShell(); if (presShell) { nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index 4560b16d5f6..a6278a9a7dd 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -522,8 +522,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext, event.originator = this; nsEventStatus status = nsEventStatus_eIgnore; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); // If |nsIPresShell::Destroy| has been called due to // handling the event (base class HandleDOMEvent, above), // the pres context will return a null pres shell. See diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index fc1cb41ed24..9afaf035b8e 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -1590,8 +1590,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, nsCOMPtr form(do_QueryInterface(mForm)); if (form) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsCOMPtr formControl = this; // kungFuDeathGrip @@ -1699,8 +1698,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, } NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { if (submitControl) { // Fire the button's onclick handler and let the button handle @@ -1776,8 +1774,8 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, event.originator = this; nsEventStatus status = nsEventStatus_eIgnore; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); + // If |nsIPresShell::Destroy| has been called due to // handling the event (base class HandleDOMEvent, above), // the pres context will return a null pres shell. See diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index f0690a06f61..cbfc383bafc 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -737,9 +737,8 @@ HTMLStyleSheetImpl::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, static nsresult GetBodyColor(nsIPresContext* aPresContext, nscolor* aColor) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr doc; + nsIPresShell *shell = aPresContext->PresShell(); shell->GetDocument(getter_AddRefs(doc)); nsCOMPtr domdoc = do_QueryInterface(doc); if (!domdoc) diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index ebbc98cdfa6..908fafc81db 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -446,10 +446,11 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext, event.isAlt = keyEvent->isAlt; event.isMeta = keyEvent->isMeta; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { ret = presShell->HandleDOMEventWithTarget(this, &event, &status); + // presShell may no longer be alive, don't use it here + // unless you keep a reference. } } } diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index af8f7d6d30c..f0fb6c173c1 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -1200,7 +1200,7 @@ nsDocShell::GetPresShell(nsIPresShell ** aPresShell) (void) GetPresContext(getter_AddRefs(presContext)); if (presContext) { - rv = presContext->GetShell(aPresShell); + NS_IF_ADDREF(*aPresShell = presContext->GetPresShell()); } return rv; @@ -1218,7 +1218,7 @@ nsDocShell::GetEldestPresShell(nsIPresShell** aPresShell) (void) GetEldestPresContext(getter_AddRefs(presContext)); if (presContext) { - rv = presContext->GetShell(aPresShell); + NS_IF_ADDREF(*aPresShell = presContext->GetPresShell()); } return rv; diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 11c39432e9e..1895552b934 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -462,8 +462,7 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, mWebBrowser->mDocShell->GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); - nsCOMPtr presShell; - presContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = presContext->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(presShell->ResizeReflow(NS_UNCONSTRAINEDSIZE, diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp index 0ae3d1103bc..f76da1ac416 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermUtils.cpp @@ -142,8 +142,6 @@ NS_EXPORT nsresult mozXMLTermUtils::GetPresContextScrollableView(nsIPresContext* aPresContext, nsIScrollableView** aScrollableView) { - nsresult result; - XMLT_LOG(mozXMLTermUtils::GetPresContextScrollableView,30,("\n")); if (!aScrollableView) @@ -151,9 +149,8 @@ mozXMLTermUtils::GetPresContextScrollableView(nsIPresContext* aPresContext, *aScrollableView = nsnull; - nsCOMPtr presShell; - result = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_FAILED(result) || !presShell) + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (!presShell) return NS_ERROR_FAILURE; nsIViewManager* viewManager = presShell->GetViewManager(); diff --git a/mozilla/gfx/src/mac/nsNativeThemeMac.cpp b/mozilla/gfx/src/mac/nsNativeThemeMac.cpp index 0b47aea0a14..6fbbb04f3a8 100644 --- a/mozilla/gfx/src/mac/nsNativeThemeMac.cpp +++ b/mozilla/gfx/src/mac/nsNativeThemeMac.cpp @@ -756,12 +756,8 @@ nsNativeThemeMac::ThemeSupportsWidget(nsIPresContext* aPresContext, nsIFrame* aF return PR_FALSE; #endif - if (aPresContext) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - if (!shell->IsThemeSupportEnabled()) - return PR_FALSE; - } + if (aPresContext && !aPresContext->PresShell()->IsThemeSupportEnabled()) + return PR_FALSE; PRBool retVal = PR_FALSE; diff --git a/mozilla/gfx/src/windows/nsNativeThemeWin.cpp b/mozilla/gfx/src/windows/nsNativeThemeWin.cpp index 1ecb34f72c4..8ea3de24d54 100644 --- a/mozilla/gfx/src/windows/nsNativeThemeWin.cpp +++ b/mozilla/gfx/src/windows/nsNativeThemeWin.cpp @@ -1152,12 +1152,8 @@ nsNativeThemeWin::ThemeSupportsWidget(nsIPresContext* aPresContext, // XXXdwh We can go even further and call the API to ask if support exists for // specific widgets. - if (aPresContext) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - if (!shell->IsThemeSupportEnabled()) - return PR_FALSE; - } + if (aPresContext && !aPresContext->PresShell()->IsThemeSupportEnabled()) + return PR_FALSE; HANDLE theme = NULL; if (aWidgetType == NS_THEME_CHECKBOX_CONTAINER) diff --git a/mozilla/layout/base/nsBidiPresUtils.cpp b/mozilla/layout/base/nsBidiPresUtils.cpp index b24255e6fba..1ffb868e971 100644 --- a/mozilla/layout/base/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/nsBidiPresUtils.cpp @@ -114,8 +114,7 @@ CreateBidiContinuation(nsIPresContext* aPresContext, NS_PRECONDITION(aFrame, "null ptr"); - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell) ); + nsIPresShell *presShell = aPresContext->PresShell(); NS_ASSERTION(presShell, "PresShell must be set on PresContext before calling nsBidiPresUtils::CreateBidiContinuation"); @@ -787,8 +786,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext, PRInt32 index; nsIFrame* parent = aFrame->GetParent(); - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell) ); + nsIPresShell *presShell = aPresContext->PresShell(); aOffset = 0; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 09b6528a6ef..a9042d59d15 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -779,7 +779,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon mFrameState(aHistoryState), mPseudoFrames() { - aPresContext->GetShell(getter_AddRefs(mPresShell)); + mPresShell = aPresContext->PresShell(); mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); } @@ -794,7 +794,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon mFirstLineStyle(PR_FALSE), mPseudoFrames() { - aPresContext->GetShell(getter_AddRefs(mPresShell)); + mPresShell = aPresContext->PresShell(); mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); nsCOMPtr container; aPresContext->GetContainer(getter_AddRefs(container)); @@ -1358,8 +1358,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex const nsStyleContentData &data = aStyleContent->ContentAt(aContentIndex); nsStyleContentType type = data.mType; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); if (eStyleContentType_URL == type) { // Create an HTML image content object, and set the SRC. @@ -4343,9 +4342,6 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel return rv; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - // Initialize it nsIFrame* geometricParent = aParentFrame; @@ -4363,7 +4359,8 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel nsHTMLContainerFrame::CreateViewForFrame(newFrame, aParentFrame, PR_FALSE); nsIFrame* areaFrame; - NS_NewAreaFrame(shell, &areaFrame, NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP); + NS_NewAreaFrame(aPresContext->PresShell(), &areaFrame, + NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP); // Resolve style and initialize the frame nsRefPtr styleContext; @@ -7215,8 +7212,7 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte #endif nsresult rv = NS_OK; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (mDocument && shell) { nsIContent *rootContent = mDocument->GetRootContent(); @@ -8008,7 +8004,7 @@ static nsresult InsertOutOfFlow(nsIPresContext* aPresContext, aFrameItems.containingBlock->GetContent()) < 0) { // lastChild comes before the new children, so insert after lastChild return aFrameItems.containingBlock-> - AppendFrames(aPresContext, *aPresContext->GetPresShell(), + AppendFrames(aPresContext, *(aPresContext->PresShell()), aChildListName, aFrameItems.childList); } } @@ -8027,7 +8023,7 @@ static nsresult InsertOutOfFlow(nsIPresContext* aPresContext, } return aFrameItems.containingBlock-> - InsertFrames(aPresContext, *aPresContext->GetPresShell(), + InsertFrames(aPresContext, *(aPresContext->PresShell()), aChildListName, insertionPoint, aFrameItems.childList); } @@ -8073,8 +8069,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); #ifdef MOZ_XUL if (aContainer) { @@ -8722,8 +8717,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsresult rv = NS_OK; #ifdef MOZ_XUL @@ -9275,8 +9269,7 @@ nsCSSFrameConstructor::RemoveMappingsForFrameSubtree(nsIPresContext* aPresContex nsIFrame* aRemovedFrame, nsILayoutHistoryState* aFrameState) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -9308,8 +9301,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); nsresult rv = NS_OK; @@ -9710,8 +9702,7 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsChangeHint aChange) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); PRBool isPaintingSuppressed = PR_FALSE; shell->IsPaintingSuppressed(&isPaintingSuppressed); if (isPaintingSuppressed) { @@ -9794,9 +9785,6 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, aFrame = GetIBContainingBlockFor(aFrame); // Target a style-change reflow at the frame. - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand *reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, eReflowType_StyleChanged, @@ -9804,7 +9792,7 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, aAttribute); if (NS_SUCCEEDED(rv)) - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } return NS_OK; @@ -9815,13 +9803,11 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsISupports* aSubContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsresult rv = NS_OK; // Find the child frame nsIFrame* frame; - shell->GetPrimaryFrameFor(aContent, &frame); + aPresContext->PresShell()->GetPrimaryFrameFor(aContent, &frame); // Notify the first frame that maps the content. It will generate a reflow // command @@ -9888,10 +9874,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, if (!count) return NS_OK; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); // Mark frames so that we skip frames that die along the way, bug 123049. // A frame can be in the list multiple times with different hints. Further @@ -9940,8 +9924,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, // reget from content since it may have been regenerated... if (content) { nsIFrame* frame; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); shell->GetPrimaryFrameFor(content, &frame); if (frame) { nsCOMPtr frameManager; @@ -9986,8 +9969,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, { nsresult result = NS_OK; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); NS_ASSERTION(shell, "couldn't get pres shell"); if (shell) { @@ -10135,8 +10117,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr kungFuDeathGrip(this); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); // Get the frame associated with the content which is the highest in the frame tree nsIFrame* primaryFrame; @@ -10441,8 +10422,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell, // If the frame is out of the flow, then it has a placeholder frame. nsPlaceholderFrame* placeholderFrame = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); if (listName) { presShell->GetPlaceholderFrameFor(aFrame, (nsIFrame**)&placeholderFrame); } @@ -11183,10 +11163,6 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext, *aFrame = nsnull; // initialize OUT parameter - // Get the pres shell - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - // We want to be able to quickly map from a content object to its frame, // but we also want to keep the hash table small. Therefore, many frames // are not added to the hash table when they're first created: @@ -11349,11 +11325,10 @@ nsCSSFrameConstructor::CaptureStateForFramesOf(nsIPresContext* aPresContext, nsIContent* aContent, nsILayoutHistoryState* aHistoryState) { - nsCOMPtr presShell; nsresult rv = NS_OK; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_SUCCEEDED(rv) && presShell) { + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (presShell) { nsIFrame* frame; rv = presShell->GetPrimaryFrameFor(aContent, &frame); if (NS_SUCCEEDED(rv) && frame) { @@ -11372,9 +11347,8 @@ nsCSSFrameConstructor::CaptureStateFor(nsIPresContext* aPresContext, nsresult rv = NS_OK; if (aFrame && aPresContext && aHistoryState) { - nsCOMPtr presShell; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_SUCCEEDED(rv) && presShell) { + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (presShell) { nsCOMPtr frameManager; rv = presShell->GetFrameManager(getter_AddRefs(frameManager)); if (NS_SUCCEEDED(rv) && frameManager) { @@ -11390,10 +11364,8 @@ nsCSSFrameConstructor::MaybeRecreateFramesForContent(nsIPresContext* aPresContex nsIContent* aContent) { nsresult result = NS_OK; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aContent); if (oldContext) { @@ -11424,8 +11396,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, // content (which would otherwise result in *two* nested reframe // containing block from ContentRemoved() and ContentInserted(), // below!) - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsIFrame* frame; shell->GetPrimaryFrameFor(aContent, &frame); @@ -12573,8 +12544,6 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, nsILayoutHistoryState* aFrameState) { #ifdef MOZ_XUL - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsresult rv = NS_OK; // Construct a new frame @@ -12600,7 +12569,8 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, PRInt32 namespaceID; aChild->GetNameSpaceID(&namespaceID); - rv = ConstructFrameInternal(shell, aPresContext, state, aChild, + rv = ConstructFrameInternal(aPresContext->PresShell(), + aPresContext, state, aChild, aParentFrame, aChild->Tag(), namespaceID, styleContext, frameItems, PR_FALSE); @@ -13087,8 +13057,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, nsCOMPtr presShell; nsCOMPtr frameManager; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); // Destroy the frames. As we do make sure any content to frame mappings // or entries in the undisplayed content map are removed @@ -13243,8 +13212,7 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, if (! aBlockChildFrame) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); if (IsBlockFrame(aPresContext, aFrame)) { // If aFrame is a block frame, then we're done: make @@ -13415,10 +13383,8 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); PRBool isReflowing; - shell->IsReflowLocked(&isReflowing); + aPresContext->PresShell()->IsReflowLocked(&isReflowing); if(isReflowing) { // don't ReframeContainingBlock, this will result in a crash // if we remove a tree that's in reflow - see bug 121368 for testcase diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index c7641825993..4953420de55 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -1547,8 +1547,7 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, NS_ASSERTION(aPresContext, "null params not allowed"); PRBool result = PR_FALSE; // assume we did not find the HTML element - nsIPresShell* shell = nsnull; - aPresContext->GetShell(&shell); + nsIPresShell* shell = aPresContext->GetPresShell(); if (shell) { nsIDocument *doc = nsnull; if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) { @@ -1582,7 +1581,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, }// if content NS_RELEASE(doc); }// if doc - NS_RELEASE(shell); } // if shell return result; @@ -2688,10 +2686,9 @@ FindCanvasBackground(nsIPresContext* aPresContext, // and thus |InitialReflow| on the pres shell. See bug 119351 // for the ugly details. if (bodyContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame *bodyFrame; - nsresult rv = shell->GetPrimaryFrameFor(bodyContent, &bodyFrame); + nsresult rv = aPresContext->PresShell()-> + GetPrimaryFrameFor(bodyContent, &bodyFrame); if (NS_SUCCEEDED(rv) && bodyFrame) result = bodyFrame->GetStyleBackground(); } @@ -3080,12 +3077,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext, } else { // The viewport isn't scrollable, so use the root frame's view - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - NS_ASSERTION(presShell, "no pres shell"); - nsIFrame* rootFrame; - presShell->GetRootFrame(&rootFrame); + aPresContext->PresShell()->GetRootFrame(&rootFrame); NS_ASSERTION(rootFrame, "no root frame"); PRBool isPaginated = PR_FALSE; diff --git a/mozilla/layout/base/nsFrameTraversal.cpp b/mozilla/layout/base/nsFrameTraversal.cpp index e91b3117681..9d28c0e8198 100644 --- a/mozilla/layout/base/nsFrameTraversal.cpp +++ b/mozilla/layout/base/nsFrameTraversal.cpp @@ -495,8 +495,7 @@ nsIFrame* nsFocusIterator::GetPlaceholderFrame(nsIFrame* aFrame) { nsIFrame* result = aFrame; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { nsIFrame* placeholder = 0; presShell->GetPlaceholderFrameFor(aFrame, &placeholder); diff --git a/mozilla/layout/base/nsImageLoader.cpp b/mozilla/layout/base/nsImageLoader.cpp index 2bab305f34a..60ce24d52dd 100644 --- a/mozilla/layout/base/nsImageLoader.cpp +++ b/mozilla/layout/base/nsImageLoader.cpp @@ -90,12 +90,11 @@ nsImageLoader::Load(nsIURI *aURI) if (!aURI) return NS_ERROR_FAILURE; - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if ((NS_FAILED(rv)) || (!shell)) return NS_ERROR_FAILURE; + nsIPresShell *shell = mPresContext->GetPresShell(); + if (!shell) return NS_ERROR_FAILURE; nsCOMPtr doc; - rv = shell->GetDocument(getter_AddRefs(doc)); + nsresult rv = shell->GetDocument(getter_AddRefs(doc)); if (NS_FAILED(rv)) return rv; // Get the document's loadgroup diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 9e37f3c49b6..3cc14131824 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -707,15 +707,6 @@ nsPresContext::SetShell(nsIPresShell* aShell) return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetShell(nsIPresShell** aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mShell; - NS_IF_ADDREF(mShell); - return NS_OK; -} - void nsPresContext::UpdateCharSet(const char* aCharSet) { diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 5d9c73f7e09..cbd65cdae25 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -132,8 +132,13 @@ public: /** * Get the PresentationShell that this context is bound to. */ - NS_IMETHOD GetShell(nsIPresShell** aResult) = 0; - nsIPresShell* GetPresShell() { return mShell; } + nsIPresShell* PresShell() const + { + NS_ASSERTION(mShell, "Null pres shell"); + return mShell; + } + + nsIPresShell* GetPresShell() const { return mShell; } nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index bd46d2724bb..17e4ca943c2 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -884,11 +884,8 @@ IncrementalReflow::Dispatch(nsIPresContext *aPresContext, nsReflowPath *path = NS_STATIC_CAST(nsReflowPath *, mRoots[i]); nsIFrame *first = path->mFrame; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsIFrame* root; - shell->GetRootFrame(&root); + aPresContext->PresShell()->GetRootFrame(&root); first->WillReflow(aPresContext); nsContainerFrame::PositionFrameView(aPresContext, first); @@ -6879,20 +6876,16 @@ CompareTrees(nsIPresContext* aFirstPresContext, nsIFrame* aFirstFrame, // verify that neither frame has a space manager, // or they both do and the space managers are equivalent nsCOMPtrfm1; - nsCOMPtr ps1; nsSpaceManager *sm1; - aFirstPresContext->GetShell(getter_AddRefs(ps1)); - NS_ASSERTION(ps1, "no pres shell for primary tree!"); + nsIPresShell *ps1 = aFirstPresContext->PresShell(); ps1->GetFrameManager(getter_AddRefs(fm1)); NS_ASSERTION(fm1, "no frame manager for primary tree!"); fm1->GetFrameProperty((nsIFrame*)k1, nsLayoutAtoms::spaceManagerProperty, 0, (void **)&sm1); // look at the test frame nsCOMPtrfm2; - nsCOMPtr ps2; nsSpaceManager *sm2; - aSecondPresContext->GetShell(getter_AddRefs(ps2)); - NS_ASSERTION(ps2, "no pres shell for test tree!"); + nsIPresShell *ps2 = aSecondPresContext->PresShell(); ps2->GetFrameManager(getter_AddRefs(fm2)); NS_ASSERTION(fm2, "no frame manager for test tree!"); fm2->GetFrameProperty((nsIFrame*)k2, nsLayoutAtoms::spaceManagerProperty, diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 5d9c73f7e09..cbd65cdae25 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -132,8 +132,13 @@ public: /** * Get the PresentationShell that this context is bound to. */ - NS_IMETHOD GetShell(nsIPresShell** aResult) = 0; - nsIPresShell* GetPresShell() { return mShell; } + nsIPresShell* PresShell() const + { + NS_ASSERTION(mShell, "Null pres shell"); + return mShell; + } + + nsIPresShell* GetPresShell() const { return mShell; } nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 5d9c73f7e09..cbd65cdae25 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -132,8 +132,13 @@ public: /** * Get the PresentationShell that this context is bound to. */ - NS_IMETHOD GetShell(nsIPresShell** aResult) = 0; - nsIPresShell* GetPresShell() { return mShell; } + nsIPresShell* PresShell() const + { + NS_ASSERTION(mShell, "Null pres shell"); + return mShell; + } + + nsIPresShell* GetPresShell() const { return mShell; } nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); } nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); } diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index b24255e6fba..1ffb868e971 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -114,8 +114,7 @@ CreateBidiContinuation(nsIPresContext* aPresContext, NS_PRECONDITION(aFrame, "null ptr"); - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell) ); + nsIPresShell *presShell = aPresContext->PresShell(); NS_ASSERTION(presShell, "PresShell must be set on PresContext before calling nsBidiPresUtils::CreateBidiContinuation"); @@ -787,8 +786,7 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* aPresContext, PRInt32 index; nsIFrame* parent = aFrame->GetParent(); - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell) ); + nsIPresShell *presShell = aPresContext->PresShell(); aOffset = 0; diff --git a/mozilla/layout/base/src/nsFrameTraversal.cpp b/mozilla/layout/base/src/nsFrameTraversal.cpp index e91b3117681..9d28c0e8198 100644 --- a/mozilla/layout/base/src/nsFrameTraversal.cpp +++ b/mozilla/layout/base/src/nsFrameTraversal.cpp @@ -495,8 +495,7 @@ nsIFrame* nsFocusIterator::GetPlaceholderFrame(nsIFrame* aFrame) { nsIFrame* result = aFrame; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { nsIFrame* placeholder = 0; presShell->GetPlaceholderFrameFor(aFrame, &placeholder); diff --git a/mozilla/layout/base/src/nsImageLoader.cpp b/mozilla/layout/base/src/nsImageLoader.cpp index 2bab305f34a..60ce24d52dd 100644 --- a/mozilla/layout/base/src/nsImageLoader.cpp +++ b/mozilla/layout/base/src/nsImageLoader.cpp @@ -90,12 +90,11 @@ nsImageLoader::Load(nsIURI *aURI) if (!aURI) return NS_ERROR_FAILURE; - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if ((NS_FAILED(rv)) || (!shell)) return NS_ERROR_FAILURE; + nsIPresShell *shell = mPresContext->GetPresShell(); + if (!shell) return NS_ERROR_FAILURE; nsCOMPtr doc; - rv = shell->GetDocument(getter_AddRefs(doc)); + nsresult rv = shell->GetDocument(getter_AddRefs(doc)); if (NS_FAILED(rv)) return rv; // Get the document's loadgroup diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 9e37f3c49b6..3cc14131824 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -707,15 +707,6 @@ nsPresContext::SetShell(nsIPresShell* aShell) return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetShell(nsIPresShell** aResult) -{ - NS_PRECONDITION(aResult, "null out param"); - *aResult = mShell; - NS_IF_ADDREF(mShell); - return NS_OK; -} - void nsPresContext::UpdateCharSet(const char* aCharSet) { diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index a9061b5b1e5..32bf2188dcc 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -71,7 +71,6 @@ public: // nsIPresContext methods NS_IMETHOD Init(nsIDeviceContext* aDeviceContext); NS_IMETHOD SetShell(nsIPresShell* aShell); - NS_IMETHOD GetShell(nsIPresShell** aResult); NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult); NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode); NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult); diff --git a/mozilla/layout/base/src/nsSpaceManager.cpp b/mozilla/layout/base/src/nsSpaceManager.cpp index e025977f48b..b1f2726005f 100644 --- a/mozilla/layout/base/src/nsSpaceManager.cpp +++ b/mozilla/layout/base/src/nsSpaceManager.cpp @@ -1413,9 +1413,7 @@ nsAutoSpaceManager::CreateSpaceManagerFor(nsIPresContext *aPresContext, nsIFrame // Create a new space manager and install it in the reflow // state. `Remember' the old space manager so we can restore it // later. - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - mNew = new nsSpaceManager(shell, aFrame); + mNew = new nsSpaceManager(aPresContext->PresShell(), aFrame); if (! mNew) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 6bda6ffbdbb..884bb623dbb 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -544,8 +544,7 @@ void nsComboboxControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); @@ -587,10 +586,9 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) event.clickCount = 0; event.widget = nsnull; - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) - rv = shell->HandleDOMEventWithTarget(mContent, &event, &status); + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) + shell->HandleDOMEventWithTarget(mContent, &event, &status); } // Show the dropdown list @@ -624,9 +622,7 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList) mDroppedDown = PR_FALSE; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->FlushPendingNotifications(PR_FALSE); + aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); if (widget) widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList); @@ -696,14 +692,12 @@ nsComboboxControlFrame::SetChildFrameSize(nsIFrame* aFrame, nscoord aWidth, nsco nsresult nsComboboxControlFrame::GetPrimaryComboFrame(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame** aFrame) { - nsresult rv = NS_OK; // Get the primary frame from the presentation shell. - nsCOMPtr presShell; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_SUCCEEDED(rv) && presShell) { + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (presShell) { presShell->GetPrimaryFrameFor(aContent, aFrame); } - return rv; + return NS_OK; } nsresult @@ -1841,13 +1835,9 @@ nsComboboxControlFrame::RedisplayText(PRInt32 aIndex) rv = ActuallyDisplayText(textToDisplay, PR_TRUE); //mTextFrame->AddStateBits(NS_FRAME_IS_DIRTY); mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY); - nsCOMPtr shell; - rv = mPresContext->GetShell(getter_AddRefs(shell)); - ReflowDirtyChild(shell, (nsIFrame*) mDisplayFrame); + ReflowDirtyChild(mPresContext->PresShell(), mDisplayFrame); -// nsCOMPtr presShell; -// mPresContext->GetShell(getter_AddRefs(presShell)); -// presShell->FlushPendingNotifications(PR_FALSE); +// mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } } return rv; @@ -2049,8 +2039,7 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) return NS_OK; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); if (NS_FAILED(rv)) { return rv; } if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } @@ -2072,9 +2061,7 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) nsCOMPtr content(do_QueryInterface(mDisplayContent)); mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); mTextFrame->SetInitialChildList(aPresContext, nsnull, nsnull); - nsCOMPtr presShell; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_FAILED(rv)) { return rv; } + nsIPresShell *presShell = aPresContext->GetPresShell(); if (!presShell) { return NS_ERROR_NULL_POINTER; } nsCOMPtr frameManager; rv = presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -2180,8 +2167,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, nsCOMPtr content(do_QueryInterface(mDisplayContent)); if (aContent == content.get()) { // Get PresShell - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); // Start by by creating a containing frame nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 350750fac0f..c0aae057c64 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -234,8 +234,7 @@ void nsFileControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 45b8389fc94..00c69c2e1ba 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -632,8 +632,7 @@ void nsFormControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 65ac8e29527..d3e6c794136 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -507,14 +507,11 @@ void nsFormControlHelper::StyleChangeReflow(nsIPresContext* aPresContext, nsIFrame* aFrame) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, eReflowType_StyleChanged); if (NS_SUCCEEDED(rv)) { - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } } diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index 995de696671..4e0ea271123 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -231,13 +231,10 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext, nsCOMPtr content(do_QueryInterface(mTextContent)); if (aContent == content.get()) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsIFrame * parentFrame = mFrames.FirstChild(); nsStyleContext* styleContext = parentFrame->GetStyleContext(); - rv = NS_NewTextFrame(shell, &newFrame); + rv = NS_NewTextFrame(aPresContext->PresShell(), &newFrame); if (NS_FAILED(rv)) { return rv; } if (!newFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index 7cd540dc222..8322a1f48c0 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -136,10 +136,8 @@ nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, flags |= NS_BLOCK_SHRINK_WRAP; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* areaFrame; - NS_NewAreaFrame(shell, &areaFrame, flags); + NS_NewAreaFrame(aPresContext->PresShell(), &areaFrame, flags); mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame @@ -271,8 +269,7 @@ void nsHTMLButtonControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index 4e21fdfcd1a..d83f6fedc63 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -358,8 +358,7 @@ void nsImageControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index efaf6f0ecf6..7a08b537dfe 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -173,8 +173,7 @@ NS_IMETHODIMP nsIsIndexFrame::GetInputFrame(nsIPresContext* aPresContext, nsIFormControlFrame** oFrame) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (!mInputContent) NS_WARNING("null content - cannot restore state"); if (presShell && mInputContent) { nsIFrame *frame; @@ -315,8 +314,7 @@ void nsIsIndexFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 1b66a10b285..4e840a25bc3 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -472,9 +472,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext, // Don't allow painting of list controls when painting is suppressed. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) return NS_OK; @@ -492,10 +490,8 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext, // if we aren't selected in the mState we could be a container // so check to see if we are in the selection range if (!isSelected) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr selcon; - selcon = do_QueryInterface(shell); + selcon = do_QueryInterface(aPresContext->PresShell()); if (selcon) { nsCOMPtr selection; selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -551,8 +547,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer GetScrollableView(mPresContext, &scrollableView); if (!scrollableView) return; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (!presShell) return; nsIFrame* containerFrame; @@ -1151,9 +1146,8 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, nsIContent * option = GetOptionContent(0); if (option != nsnull) { nsIFrame * optFrame; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - nsresult result = presShell->GetPrimaryFrameFor(option, &optFrame); + nsresult result = mPresContext->PresShell()-> + GetPrimaryFrameFor(option, &optFrame); if (NS_SUCCEEDED(result) && optFrame != nsnull) { nsStyleContext* optStyle = optFrame->GetStyleContext(); if (optStyle) { @@ -2121,8 +2115,7 @@ void nsListControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); @@ -2458,8 +2451,7 @@ nsListControlFrame::FireOnChange() event.eventStructType = NS_EVENT; event.message = NS_FORM_CHANGE; - nsCOMPtr presShell; - rv = mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { rv = presShell->HandleEventWithTarget(&event, this, nsnull, NS_EVENT_FLAG_INIT, &status); @@ -2875,10 +2867,8 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, nsCOMPtr node; mouseEvent->GetTarget(getter_AddRefs(node)); nsCOMPtr content = do_QueryInterface(node); - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); nsIFrame * frame; - nsresult result = presShell->GetPrimaryFrameFor(content, &frame); + mPresContext->PresShell()->GetPrimaryFrameFor(content, &frame); printf("Target Frame: %p this: %p\n", frame, this); printf("-->\n"); #endif @@ -3063,8 +3053,7 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement) } // otherwise we find the content's frame and scroll to it - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->PresShell(); nsIFrame * childframe; nsresult result; if (aOptElement) { @@ -3497,9 +3486,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) // Why aren't they getting flushed each time? // because this isn't needed for Gfx if (IsInDropDownMode() == PR_TRUE) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - presShell->FlushPendingNotifications(PR_FALSE); + mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } REFLOW_DEBUG_MSG2(" After: %d\n", newIndex); diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index be6fc196642..5d5938eeec5 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -1635,11 +1635,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, mState |= NS_FRAME_INDEPENDENT_SELECTION; - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - - if (NS_FAILED(rv)) - return rv; + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; @@ -1647,7 +1643,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the DOM document nsCOMPtr doc; - rv = shell->GetDocument(getter_AddRefs(doc)); + nsresult rv = shell->GetDocument(getter_AddRefs(doc)); if (NS_FAILED(rv)) return rv; if (!doc) @@ -2104,8 +2100,7 @@ void nsTextControlFrame::SetFocus(PRBool aOn , PRBool aRepaint){} void nsTextControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); @@ -2685,10 +2680,9 @@ nsTextControlFrame::AttributeChanged(nsIPresContext* aPresContext, } else if (mEditor && nsHTMLAtoms::disabled == aAttribute) { - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) - return rv; + // XXXbryner do we need to check for a null presshell here? + // we don't do anything with it. + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; @@ -3068,11 +3062,8 @@ nsTextControlFrame::SetInitialChildList(nsIPresContext* aPresContext, // register the event listeners with the DOM event reveiver rv = erP->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *,mTextListener), NS_GET_IID(nsIDOMFocusListener)); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register focus listener"); - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) - return rv; - if (!shell) + // XXXbryner do we need to check for a null presshell here? + if (!aPresContext->GetPresShell()) return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index e428df71cad..1970f48e468 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -921,8 +921,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (VERIFY_REFLOW_INCLUDE_SPACE_MANAGER & verifyReflowFlags) { // this is a leak of the space manager, but it's only in debug if verify reflow is enabled, so not a big deal - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); @@ -2716,16 +2715,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, // XXX Not sure if this is necessary anymore RenumberLists(aPresContext); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ContentChanged, nsnull, aAttribute); if (NS_SUCCEEDED(rv)) - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } else if (nsHTMLAtoms::value == aAttribute) { const nsStyleDisplay* styleDisplay = GetStyleDisplay(); @@ -2751,16 +2747,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, // XXX Not sure if this is necessary anymore blockParent->RenumberLists(aPresContext); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, blockParent, eReflowType_ContentChanged, nsnull, aAttribute); if (NS_SUCCEEDED(rv)) - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } } } @@ -4559,8 +4552,7 @@ nsBlockFrame::AddFrames(nsIPresContext* aPresContext, return NS_OK; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); // Attempt to find the line that contains the previous sibling nsLineList::iterator prevSibLine = end_lines(); @@ -4735,9 +4727,8 @@ nsBlockFrame::DoRemoveOutOfFlowFrame(nsIPresContext* aPresContext, nsBlockFrame* block = (nsBlockFrame*)parent; // Remove aFrame from the appropriate list. if (display->IsAbsolutelyPositioned()) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - block->mAbsoluteContainer.RemoveFrame(block, aPresContext, *presShell, + block->mAbsoluteContainer.RemoveFrame(block, aPresContext, + *(aPresContext->PresShell()), block->mAbsoluteContainer.GetChildListName(), aFrame); } else { @@ -4756,8 +4747,7 @@ nsBlockFrame::DoRemoveFrame(nsIPresContext* aPresContext, return NS_OK; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); // Find the line and the previous sibling that contains // deletedFrame; we also find the pointer to the line. @@ -5285,9 +5275,7 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, } PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) return NS_OK; @@ -5575,9 +5563,9 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext, { nsresult result; - nsCOMPtr shell; + nsIPresShell *shell = nsnull; if (aEvent->message == NS_MOUSE_MOVE) { - aPresContext->GetShell(getter_AddRefs(shell)); + shell = aPresContext->GetPresShell(); if (!shell) return NS_OK; nsCOMPtr frameSelection; @@ -5605,7 +5593,7 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext, nsIFrame *resultFrame = nsnull;//this will be passed the handle event when we //can tell who to pass it to nsIFrame *mainframe = this; - aPresContext->GetShell(getter_AddRefs(shell)); + shell = aPresContext->GetPresShell(); if (!shell) return NS_OK; nsCOMPtr tracker( do_QueryInterface(shell, &result) ); @@ -5998,9 +5986,7 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, nsRefPtr kidSC = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, mStyleContext); // Create bullet frame - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - mBullet = new (shell.get()) nsBulletFrame; + mBullet = new (aPresContext->PresShell()) nsBulletFrame; if (nsnull == mBullet) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 62ea2819d40..972d46ebf4c 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -182,20 +182,14 @@ nsBlockReflowState::NewLineBox(nsIFrame* aFrame, PRInt32 aCount, PRBool aIsBlock) { - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - - return NS_NewLineBox(shell, aFrame, aCount, aIsBlock); + return NS_NewLineBox(mPresContext->PresShell(), aFrame, aCount, aIsBlock); } void nsBlockReflowState::FreeLineBox(nsLineBox* aLine) { if (aLine) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - - aLine->Destroy(presShell); + aLine->Destroy(mPresContext->PresShell()); } } @@ -945,10 +939,8 @@ nsBlockReflowState::FlowAndPlaceFloat(nsFloatCache* aFloatCache, if (prevInFlow) { prevRect = prevInFlow->GetRect(); - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + mPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsIFrame *placeParentPrev, *prevPlace; // If prevInFlow's placeholder is in a block that wasn't continued, we need to adjust diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp index 23e4ab19a52..9e22f338e59 100644 --- a/mozilla/layout/generic/nsBulletFrame.cpp +++ b/mozilla/layout/generic/nsBulletFrame.cpp @@ -1692,9 +1692,8 @@ NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, // Now that the size is available (or an error occurred), trigger // a reflow of the bullet frame. - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { NS_ASSERTION(mParent, "No parent to pass the reflow request up to."); if (mParent) { // Reflow the first child of the parent not the bullet frame. @@ -1751,10 +1750,6 @@ NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest, #if 0 NS_ENSURE_TRUE(mPresContext, NS_ERROR_UNEXPECTED); // Why are we bothering? - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(aStatus)) { // We failed to load the image. Notify the pres shell if (NS_FAILED(aStatus) && (mImageRequest == aRequest || !mImageRequest)) { @@ -1794,8 +1789,7 @@ nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGr NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer"); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return; diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index dc3a3076c6f..677fcc78fab 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -591,10 +591,8 @@ SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, viewHasTransparentContent = PR_FALSE; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr doc; - shell->GetDocument(getter_AddRefs(doc)); + aPresContext->PresShell()->GetDocument(getter_AddRefs(doc)); if (doc) { nsIContent *rootElem = doc->GetRootContent(); if (!doc->GetParentDocument() && @@ -1126,8 +1124,7 @@ nsIFrame* nsContainerFrame::GetOverflowFrames(nsIPresContext* aPresContext, PRBool aRemoveProperty) const { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -1167,10 +1164,9 @@ nsresult nsContainerFrame::SetOverflowFrames(nsIPresContext* aPresContext, nsIFrame* aOverflowFrames) { - nsCOMPtr presShell; nsresult rv = NS_ERROR_FAILURE; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index ab626529da5..dad87ba4c4c 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -220,8 +220,7 @@ nsIFrameDebug::RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aI if((nsnull == aPresContext) || (nsnull == out)) return; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (nsnull != shell) { nsIFrame* frame; shell->GetRootFrame(&frame); @@ -612,8 +611,7 @@ nsFrame::ReplaceFrame(nsIPresContext* aPresContext, NS_IMETHODIMP nsFrame::Destroy(nsIPresContext* aPresContext) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); // Get the view pointer now before the frame properties disappear // when we call NotifyDestroyingFrame() @@ -826,10 +824,7 @@ nsFrame::Paint(nsIPresContext* aPresContext, return NS_OK; nsresult result; - nsCOMPtr shell; - result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; + nsIPresShell *shell = aPresContext->PresShell(); PRInt16 displaySelection = nsISelectionDisplay::DISPLAY_ALL; if (!(aFlags & nsISelectionDisplay::DISPLAY_IMAGES)) @@ -975,24 +970,19 @@ nsFrame::HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); switch (aEvent->message) { case NS_MOUSE_MOVE: { - if (NS_SUCCEEDED(rv)) - rv = HandleDrag(aPresContext, aEvent, aEventStatus); + HandleDrag(aPresContext, aEvent, aEventStatus); }break; case NS_MOUSE_LEFT_BUTTON_DOWN: { - if (NS_SUCCEEDED(rv)) - HandlePress(aPresContext, aEvent, aEventStatus); + HandlePress(aPresContext, aEvent, aEventStatus); }break; case NS_MOUSE_LEFT_BUTTON_UP: { - if (NS_SUCCEEDED(rv)) - HandleRelease(aPresContext, aEvent, aEventStatus); + HandleRelease(aPresContext, aEvent, aEventStatus); } break; default: break; @@ -1216,15 +1206,13 @@ ContentContainsPoint(nsIPresContext *aPresContext, nsPoint *aPoint, nsIView *aRelativeView) { - nsCOMPtr presShell; + nsIPresShell *presShell = aPresContext->GetPresShell(); - nsresult rv = aPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(rv) || !presShell) return PR_FALSE; + if (!presShell) return PR_FALSE; nsIFrame *frame = nsnull; - rv = presShell->GetPrimaryFrameFor(aContent, &frame); + nsresult rv = presShell->GetPrimaryFrameFor(aContent, &frame); if (NS_FAILED(rv) || !frame) return PR_FALSE; @@ -1312,8 +1300,7 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, return NS_OK; nsresult rv; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; @@ -1688,12 +1675,11 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, nsIPresContext* aPresContext, PRBool aJumpLines) { - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr selcon; - if (NS_SUCCEEDED(rv)) - rv = GetSelectionController(aPresContext, getter_AddRefs(selcon)); + nsresult rv = GetSelectionController(aPresContext, getter_AddRefs(selcon)); if (NS_FAILED(rv)) return rv; + + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell || !selcon) return NS_ERROR_NOT_INITIALIZED; @@ -1759,7 +1745,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, nsCOMPtr frameselection = do_QueryInterface(selcon); //this MAY implement if (!frameselection) { - rv = aPresContext->GetPresShell()->GetFrameSelection(getter_AddRefs(frameselection)); + rv = aPresContext->PresShell()->GetFrameSelection(getter_AddRefs(frameselection)); if (NS_FAILED(rv) || !frameselection) return NS_OK; // return NS_OK; we don't care if this fails } @@ -1778,19 +1764,13 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext* aPresContext, if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) { return NS_OK; } - nsresult result; - - nsCOMPtr presShell; - - result = aPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(result)) - return result; + nsIPresShell *presShell = aPresContext->PresShell(); nsCOMPtr frameselection; nsCOMPtr selCon; - result = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult result = GetSelectionController(aPresContext, + getter_AddRefs(selCon)); if (NS_SUCCEEDED(result) && selCon) { frameselection = do_QueryInterface(selCon); //this MAY implement @@ -1845,14 +1825,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext* aPresContext, if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) return NS_OK; - nsresult result; - - nsCOMPtr presShell; - - result = aPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(result)) - return result; + nsIPresShell *presShell = aPresContext->GetPresShell(); if (!presShell) return NS_ERROR_FAILURE; @@ -1860,7 +1833,8 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext* aPresContext, nsCOMPtr frameselection; nsCOMPtr selCon; - result = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult result = GetSelectionController(aPresContext, + getter_AddRefs(selCon)); if (NS_SUCCEEDED(result) && selCon) frameselection = do_QueryInterface(selCon); //this MAY implement @@ -2262,12 +2236,12 @@ nsFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = aPresContext->GetPresShell(); + + if (shell) { nsHTMLReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - eReflowType_ContentChanged); + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ContentChanged); if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); } @@ -2546,8 +2520,7 @@ nsFrame::Invalidate(nsIPresContext* aPresContext, if (aPresContext) { // Don't allow invalidates to do anything when // painting is suppressed. - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { PRBool suppressed = PR_FALSE; shell->IsPaintingSuppressed(&suppressed); @@ -2802,9 +2775,8 @@ nsFrame::GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** a // we could be a container so check to see if we are in the selection range // this is a expensive if (!isSelected) { - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr selcon(do_QueryInterface(shell)); if (selcon) { rv = selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); @@ -2872,8 +2844,8 @@ nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionContro tmp = tmp->GetParent(); } } - nsCOMPtr shell; - if (NS_SUCCEEDED(aPresContext->GetShell(getter_AddRefs(shell))) && shell) + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr selCon = do_QueryInterface(shell); NS_IF_ADDREF(*aSelCon = selCon); @@ -3257,8 +3229,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext, //special check. if we allow non-text selection then we can allow a hit location to fall before a table. //otherwise there is no way to get and click signal to fall before a table (it being a line iterator itself) PRInt16 isEditor = 0; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; shell->GetSelectionFlags ( &isEditor ); @@ -3709,8 +3680,7 @@ nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) { //if we are searching for a frame that is not in flow we will not find it. //we must instead look for its placeholder - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { @@ -4265,8 +4235,7 @@ nsFrame::GetOverflowAreaProperty(nsIPresContext* aPresContext, if (!((GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) || aCreateIfNecessary)) { return nsnull; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -4313,8 +4282,7 @@ nsFrame::StoreOverflow(nsIPresContext* aPresContext, else { if (mState & NS_FRAME_OUTSIDE_CHILDREN) { // remove the previously stored overflow area - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -4381,10 +4349,8 @@ GetIBSpecialSibling(nsIPresContext* aPresContext, * property, which is only set on the anonymous block frames we're * interested in. */ - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsIFrame *specialSibling; nsresult rv = frameManager->GetFrameProperty(aFrame, @@ -4509,10 +4475,8 @@ nsFrame::DoGetParentStyleContextFrame(nsIPresContext* aPresContext, // For out-of-flow frames, we must resolve underneath the // placeholder's parent. - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsIFrame *placeholder; frameManager->GetPlaceholderFrameFor(this, &placeholder); if (!placeholder) { @@ -4640,10 +4604,9 @@ nsFrame::SetProperty(nsIPresContext* aPresContext, void* aPropValue, NSFramePropertyDtorFunc aPropDtorFunc) { - nsCOMPtr presShell; nsresult rv = NS_ERROR_FAILURE; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -4662,8 +4625,7 @@ nsFrame::GetProperty(nsIPresContext* aPresContext, { void* value = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -4710,8 +4672,7 @@ NS_IMETHODIMP nsFrame::GetBidiProperty(nsIPresContext* aPresContext, memset(aPropertyValue, 0, aSize); void* val = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell) ); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -4738,8 +4699,7 @@ NS_IMETHODIMP nsFrame::SetBidiProperty(nsIPresContext* aPresContext, { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell) ); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager) ); diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 1c57c0be359..da87746954a 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -374,8 +374,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, // will have been set by nsCSSFrameConstructor if necessary. nsCOMPtr contentParentAtom = do_GetAtom("contentParent"); nsIFrame* contentParent = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -402,9 +401,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, view->CreateWidget(kCChildCID); } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsIFrame* firstChild = new (shell.get()) nsHTMLFrameInnerFrame; + nsIFrame* firstChild = new (aPresContext->PresShell()) nsHTMLFrameInnerFrame; if (firstChild) { mFrames.SetFrames(firstChild); // Resolve the style context for the inner frame diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 924772f70e2..8a8da925447 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -349,8 +349,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, viewMan->InsertChild(parView, view, nsnull, PR_TRUE); SetView(view); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsFrameborder frameborder = GetFrameBorder(); PRInt32 borderWidth = GetBorderWidth(aPresContext, PR_FALSE); @@ -444,7 +443,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, for (int blankX = mChildCount; blankX < numCells; blankX++) { // XXX the blank frame is using the content of its parent - at some point it // should just have null content, if we support that - nsHTMLFramesetBlankFrame* blankFrame = new (shell.get()) nsHTMLFramesetBlankFrame; + nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame; nsRefPtr pseudoStyleContext; pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::framesetBlank, @@ -979,9 +978,8 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, { DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - + nsIPresShell *shell = aPresContext->PresShell(); + //printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight); // Always get the size so that the caller knows how big we are GetDesiredSize(aPresContext, aReflowState, aDesiredSize); @@ -1071,7 +1069,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, offset.x = 0; offset.y += lastSize.height; if (firstTime) { // create horizontal border - borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_FALSE, PR_FALSE); + borderFrame = new (shell) nsHTMLFramesetBorderFrame(borderWidth, + PR_FALSE, + PR_FALSE); nsRefPtr pseudoStyleContext; pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::horizontalFramesetBorder, @@ -1098,7 +1098,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, if (cellIndex.x > 0) { // moved to next col in same row if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border - borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_TRUE, PR_FALSE); + borderFrame = new (shell) nsHTMLFramesetBorderFrame(borderWidth, + PR_TRUE, + PR_FALSE); nsRefPtr pseudoStyleContext; pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::verticalFramesetBorder, diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 769afedfd50..6c74c18ba0e 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -359,8 +359,7 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); nsCOMPtr document; if (shell) shell->GetDocument(getter_AddRefs(document)); @@ -1053,8 +1052,7 @@ nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext, ScrollbarChanged(mOuter->mPresContext, x*mOnePixel, y*mOnePixel, isSmooth ? NS_VMREFRESH_SMOOTHSCROLL : 0); // Fire the onScroll event now that we have scrolled - nsCOMPtr presShell; - mOuter->mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mOuter->mPresContext->GetPresShell(); if (presShell) { nsScrollbarEvent event; event.eventStructType = NS_SCROLLBAR_EVENT; @@ -1620,11 +1618,10 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState) nsIFrame* child; if (NS_SUCCEEDED(parentFrame->FirstChild(mOuter->mPresContext, nsLayoutAtoms::fixedList, &child)) && child) { - nsCOMPtr presShell; - mOuter->mPresContext->GetShell(getter_AddRefs(presShell)); // force a reflow of the fixed children - nsFrame::CreateAndPostReflowCommand(presShell, parentFrame, + nsFrame::CreateAndPostReflowCommand(mOuter->mPresContext->PresShell(), + parentFrame, eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); } } diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 3b36c2cabbf..cde0cc8dd06 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -323,13 +323,8 @@ nsHTMLContainerFrame::CreateNextInFlow(nsIPresContext* aPresContext, // into our lines child list. nsIFrame* nextFrame = aFrame->GetNextSibling(); - nsIPresShell* presShell; - nsIStyleSet* styleSet; - aPresContext->GetShell(&presShell); - presShell->GetStyleSet(&styleSet); - NS_RELEASE(presShell); - styleSet->CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow); - NS_RELEASE(styleSet); + aPresContext->PresShell()->GetStyleSet()-> + CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow); if (nsnull == nextInFlow) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index 6cf463af7e3..ddc58db8608 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -382,9 +382,7 @@ CanvasFrame::Paint(nsIPresContext* aPresContext, // and frame construction. If painting is locked down, then we // do not paint our children. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { PaintSelf(aPresContext, aRenderingContext, aDirtyRect); diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 439314a4ac4..c2b82dc870c 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -938,10 +938,8 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext, // Get the placeholder frame nsIFrame* placeholderFrame; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetPlaceholderFrameFor(frame, &placeholderFrame); + aPresContext->PresShell()->GetPlaceholderFrameFor(frame, &placeholderFrame); NS_ASSERTION(nsnull != placeholderFrame, "no placeholder frame"); // Find the nearest containing block frame to the placeholder frame, diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 42291352f4e..338dc5ebdc7 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -323,14 +323,10 @@ nsImageFrame::Init(nsIPresContext* aPresContext, } if (currentLoadStatus & imgIRequest::STATUS_ERROR) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - NS_ASSERTION(presShell, "Must have a pres shell!"); - PRBool loadBlocked = PR_FALSE; imageLoader->GetImageBlocked(&loadBlocked); rv = HandleLoadError(loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE, - presShell); + mPresContext->PresShell()); } // If we already have an image container, OnStartContainer won't be called // Set the animation mode here @@ -565,8 +561,7 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) // Now we need to reflow if we have an unconstrained size and have // already gotten the initial reflow if (!(mState & IMAGE_SIZECONSTRAINED) && (mState & IMAGE_GOTINITIALREFLOW)) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); NS_ASSERTION(mParent, "No parent to pass the reflow request up to."); NS_ASSERTION(presShell, "No PresShell."); if (mParent && presShell) { @@ -639,8 +634,7 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest, { NS_ENSURE_TRUE(mPresContext, NS_ERROR_UNEXPECTED); // why are we bothering? - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); NS_ASSERTION(presShell, "No PresShell."); // handle iconLoads first... @@ -848,10 +842,8 @@ nsImageFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); mState |= NS_FRAME_IS_DIRTY; - return mParent->ReflowDirtyChild(shell, this); + return mParent->ReflowDirtyChild(aPresContext->PresShell(), this); } // get the offset into the content area of the image where aImg starts if it is a continuation. @@ -1234,9 +1226,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, // If painting is suppressed, we need to stop image painting. We // have to cover here because of input image controls. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) { return NS_OK; } @@ -1399,11 +1389,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, PRInt16 displaySelection = 0; nsresult result; - nsCOMPtr shell; - result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; - result = shell->GetSelectionFlags(&displaySelection); + result = aPresContext->PresShell()->GetSelectionFlags(&displaySelection); if (NS_FAILED(result)) return result; if (!(displaySelection & nsISelectionDisplay::DISPLAY_IMAGES)) @@ -1479,13 +1465,10 @@ nsImageFrame::GetImageMap(nsIPresContext* aPresContext) nsCOMPtr map; if (NS_SUCCEEDED(nsImageMapUtils::FindImageMap(doc,usemap,getter_AddRefs(map))) && map) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - mImageMap = new nsImageMap(); if (mImageMap) { NS_ADDREF(mImageMap); - mImageMap->Init(presShell, this, map); + mImageMap->Init(aPresContext->PresShell(), this, map); } } } @@ -1510,12 +1493,15 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, nsCOMPtr securityManager = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); - nsCOMPtr ps; - if (NS_SUCCEEDED(rv)) - rv = aPresContext->GetShell(getter_AddRefs(ps)); + if (NS_FAILED(rv)) + return; + + nsIPresShell *ps = aPresContext->GetPresShell(); + if (!ps) + return; + nsCOMPtr doc; - if (NS_SUCCEEDED(rv) && ps) - rv = ps->GetDocument(getter_AddRefs(doc)); + rv = ps->GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv)) { nsIURI *baseURI = doc ? doc->GetDocumentURL() : nsnull; @@ -1778,10 +1764,8 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext, // XXXldb Shouldn't width and height be handled by attribute mapping? if (nsHTMLAtoms::width == aAttribute || nsHTMLAtoms::height == aAttribute || nsHTMLAtoms::alt == aAttribute) { // XXX: could check for new width == old width, and make that a no-op - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); mState |= NS_FRAME_IS_DIRTY; - mParent->ReflowDirtyChild(presShell, (nsIFrame*) this); + mParent->ReflowDirtyChild(aPresContext->PresShell(), (nsIFrame*) this); } return NS_OK; @@ -1907,8 +1891,7 @@ nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGro NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer"); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return; diff --git a/mozilla/layout/generic/nsLeafFrame.cpp b/mozilla/layout/generic/nsLeafFrame.cpp index 08dfbed874f..bf00ef6173e 100644 --- a/mozilla/layout/generic/nsLeafFrame.cpp +++ b/mozilla/layout/generic/nsLeafFrame.cpp @@ -112,8 +112,6 @@ nsLeafFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); mState |= NS_FRAME_IS_DIRTY; - return mParent->ReflowDirtyChild(shell, this); + return mParent->ReflowDirtyChild(aPresContext->PresShell(), this); } diff --git a/mozilla/layout/generic/nsLineBox.cpp b/mozilla/layout/generic/nsLineBox.cpp index 371bc352c8e..cc0ebf33878 100644 --- a/mozilla/layout/generic/nsLineBox.cpp +++ b/mozilla/layout/generic/nsLineBox.cpp @@ -303,8 +303,7 @@ nsLineBox::DeleteLineList(nsIPresContext* aPresContext, nsLineList& aLines) child = nextChild; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); do { nsLineBox* line = aLines.front(); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 8da7151dab6..bdc62142425 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -644,10 +644,8 @@ nsObjectFrame::Init(nsIPresContext* aPresContext, imageLoader->ImageURIChanged(data); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame * aNewFrame = nsnull; - rv = NS_NewImageFrame(shell, &aNewFrame); + rv = NS_NewImageFrame(aPresContext->PresShell(), &aNewFrame); if (NS_FAILED(rv)) return rv; @@ -677,10 +675,8 @@ nsObjectFrame::Init(nsIPresContext* aPresContext, if(bDoc) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame * aNewFrame = nsnull; - rv = NS_NewHTMLFrameOuterFrame(shell, &aNewFrame); + rv = NS_NewHTMLFrameOuterFrame(aPresContext->PresShell(), &aNewFrame); if(NS_FAILED(rv)) return rv; @@ -1187,10 +1183,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, text->mVerticalAlign.SetNormalValue(); //check for alternative content with CantRenderReplacedElement() - nsIPresShell* presShell; - aPresContext->GetShell(&presShell); - rv = presShell->CantRenderReplacedElement(this); - NS_RELEASE(presShell); + rv = aPresContext->PresShell()->CantRenderReplacedElement(this); } else { NotifyContentObjectWrapper(); } @@ -1287,12 +1280,8 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext, nsCOMPtr element = do_QueryInterface(mContent, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) return rv; - nsCOMPtr document; - rv = shell->GetDocument(getter_AddRefs(document)); + rv = aPresContext->PresShell()->GetDocument(getter_AddRefs(document)); if (NS_FAILED(rv)) return rv; if (! document) @@ -1438,9 +1427,9 @@ nsObjectFrame::ContentChanged(nsIPresContext* aPresContext, nsISupports* aSubContent) { // Generate a reflow command with this frame as the target frame - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ContentChanged); @@ -2418,8 +2407,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument) { nsresult rv = NS_ERROR_FAILURE; if (nsnull != mContext) { - nsCOMPtr shell; - mContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mContext->GetPresShell(); if (shell) rv = shell->GetDocument(aDocument); } @@ -2617,11 +2605,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result) return NS_ERROR_FAILURE; } - nsCOMPtr shell; - mContext->GetShell(getter_AddRefs(shell)); - nsCOMPtr doc; - shell->GetDocument(getter_AddRefs(doc)); + mContext->PresShell()->GetDocument(getter_AddRefs(doc)); rv = doc->GetBaseURL()->GetSpec(mDocumentBase); } diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 92edb33ebfd..a80ba820b77 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -163,12 +163,10 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext, nsIFrame* prevLastChild = prevContentPage->mFrames.LastChild(); // Create a continuing child of the previous page's last child - nsCOMPtr presShell; nsCOMPtr styleSet; nsIFrame* newFrame; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetStyleSet(getter_AddRefs(styleSet)); + aPresContext->PresShell()->GetStyleSet(getter_AddRefs(styleSet)); styleSet->CreateContinuingFrame(aPresContext, prevLastChild, contentPage, &newFrame); // Make the new area frame the 1st child of the page content frame. There may already be // children placeholders which don't get reflowed but must not be destroyed until the diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 6ab0ffa917c..d1b7c86b2b3 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -1043,10 +1043,7 @@ nsSelection::FetchDesiredX(nscoord &aDesiredX) //the x position requested by the if (!context) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; + nsIPresShell *shell = context->GetPresShell(); if (!shell) return NS_ERROR_NULL_POINTER; @@ -1497,9 +1494,8 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA } nsCOMPtr caret; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result) || !shell) + nsIPresShell *shell = context->GetPresShell(); + if (!shell) return 0; result = shell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result) || !caret) @@ -2501,9 +2497,8 @@ void nsSelection::BidiLevelFromClick(nsIContent *aNode, PRUint32 aContentOffset) if (NS_FAILED(result) || !context) return; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result) || !shell) + nsIPresShell *shell = context->GetPresShell(); + if (!shell) return; nsIFrame* clickInFrame=nsnull; @@ -2764,8 +2759,7 @@ nsSelection::TakeFocus(nsIContent *aNewFocus, PRUint32 aContentOffset, if (NS_FAILED(result) || !presContext) return result?result:NS_ERROR_FAILURE; - nsCOMPtr presShell; - presContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = presContext->GetPresShell(); if (!presShell) return NS_ERROR_FAILURE; @@ -3082,11 +3076,7 @@ nsSelection::CommonPageMove(PRBool aForward, if (!context) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - - if (NS_FAILED(result)) - return result; + nsIPresShell *shell = context->GetPresShell(); if (!shell) return NS_ERROR_NULL_POINTER; @@ -5067,10 +5057,7 @@ nsTypedSelection::selectFrames(nsIPresContext* aPresContext, nsIDOMRange *aRange if ((NS_SUCCEEDED(result)) && iter && inneriter) { - nsCOMPtr presShell; - result = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_FAILED(result) && presShell) - presShell = 0; + nsIPresShell *presShell = aPresContext->GetPresShell(); #ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE nsCOMPtr genericiter = do_QueryInterface(iter); if (genericiter && presShell) @@ -6881,8 +6868,7 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell) if (!presContext) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - rv = presContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = presContext->GetPresShell(); mPresShellWeak = do_GetWeakReference(shell); // the presshell owns us, so no addref if (mPresShellWeak) NS_ADDREF(*aPresShell = shell); @@ -7719,10 +7705,9 @@ nsTypedSelection::SelectionLanguageChange(PRBool aLangRTL) mFrameSelection->GetPrevNextBidiLevels(context, focusContent, focusOffset, &frameBefore, &frameAfter, &levelBefore, &levelAfter); } - nsCOMPtr shell; - result = context->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result) || !shell) - return result?result:NS_ERROR_FAILURE; + nsIPresShell* shell = context->GetPresShell(); + if (!shell) + return NS_ERROR_FAILURE; if ((levelBefore & 1) == (levelAfter & 1)) { // if cursor is between two characters with the same orientation, changing the keyboard language diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 34400d27531..7025b95cbe3 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -203,17 +203,9 @@ nsSimplePageSequenceFrame::CreateContinuingPageFrame(nsIPresContext* aPresContex nsIFrame* aPageFrame, nsIFrame** aContinuingPage) { - nsIPresShell* presShell; - nsIStyleSet* styleSet; - nsresult rv; - // Create the continuing frame - aPresContext->GetShell(&presShell); - presShell->GetStyleSet(&styleSet); - NS_RELEASE(presShell); - rv = styleSet->CreateContinuingFrame(aPresContext, aPageFrame, this, aContinuingPage); - NS_RELEASE(styleSet); - return rv; + return aPresContext->PresShell()->GetStyleSet()-> + CreateContinuingFrame(aPresContext, aPageFrame, this, aContinuingPage); } void diff --git a/mozilla/layout/generic/nsSpaceManager.cpp b/mozilla/layout/generic/nsSpaceManager.cpp index e025977f48b..b1f2726005f 100644 --- a/mozilla/layout/generic/nsSpaceManager.cpp +++ b/mozilla/layout/generic/nsSpaceManager.cpp @@ -1413,9 +1413,7 @@ nsAutoSpaceManager::CreateSpaceManagerFor(nsIPresContext *aPresContext, nsIFrame // Create a new space manager and install it in the reflow // state. `Remember' the old space manager so we can restore it // later. - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - mNew = new nsSpaceManager(shell, aFrame); + mNew = new nsSpaceManager(aPresContext->PresShell(), aFrame); if (! mNew) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index f4924b0c093..764a51af86d 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -1335,7 +1335,7 @@ nsTextFrame::GetDocument(nsIPresContext* aPresContext) NS_IF_ADDREF(result = mContent->GetDocument()); } if (!result && aPresContext) { - aPresContext->GetPresShell()->GetDocument(&result); + aPresContext->PresShell()->GetDocument(&result); } return result; } @@ -1402,15 +1402,13 @@ nsTextFrame::ContentChanged(nsIPresContext* aPresContext, } // Ask the parent frame to reflow me. - nsresult rv; - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell && mParent) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell && mParent) { mParent->ReflowDirtyChild(shell, targetTextFrame); } - return rv; + return NS_OK; } NS_IMETHODIMP @@ -2014,12 +2012,12 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsIPresContext* aPresConte NS_ENSURE_ARG_POINTER(aLineBreaker); //get the presshell - nsresult rv = aPresContext->GetShell(aPresShell); - if (NS_FAILED(rv) || (*aPresShell) == nsnull) + NS_IF_ADDREF(*aPresShell = aPresContext->GetPresShell()); + if (!*aPresShell) return NS_ERROR_FAILURE; //get the selection controller - rv = GetSelectionController(aPresContext, aSelectionController); + nsresult rv = GetSelectionController(aPresContext, aSelectionController); if (NS_FAILED(rv) || !(*aSelectionController)) return NS_ERROR_FAILURE; @@ -3376,11 +3374,10 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, // initialize out param *aNewContent = nsnull; - nsCOMPtr shell; - nsresult rv = aCX->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aCX->GetPresShell(); + if (shell) { nsCOMPtr acx; - rv = shell->CreateRenderingContext(this, getter_AddRefs(acx)); + nsresult rv = shell->CreateRenderingContext(this, getter_AddRefs(acx)); if (NS_SUCCEEDED(rv)) { TextStyle ts(aCX, *acx, mStyleContext); if (ts.mSmallCaps || ts.mWordSpacing || ts.mLetterSpacing || ts.mJustifying) { @@ -3632,13 +3629,13 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext, else {//we need to see if any other selection available. SelectionDetails *details = nsnull; - nsCOMPtr shell; nsCOMPtr frameSelection; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr selCon; - rv = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult rv = GetSelectionController(aPresContext, + getter_AddRefs(selCon)); if (NS_SUCCEEDED(rv) && selCon) { frameSelection = do_QueryInterface(selCon); //this MAY implement @@ -4383,10 +4380,7 @@ nsTextFrame::CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRIn if (aStartIndex < (mContentOffset + mContentLength)) { //get the presshell - nsCOMPtr shell; - rv = aContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) - return rv; + nsIPresShell *shell = aContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index e428df71cad..1970f48e468 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -921,8 +921,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (VERIFY_REFLOW_INCLUDE_SPACE_MANAGER & verifyReflowFlags) { // this is a leak of the space manager, but it's only in debug if verify reflow is enabled, so not a big deal - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); @@ -2716,16 +2715,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, // XXX Not sure if this is necessary anymore RenumberLists(aPresContext); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ContentChanged, nsnull, aAttribute); if (NS_SUCCEEDED(rv)) - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } else if (nsHTMLAtoms::value == aAttribute) { const nsStyleDisplay* styleDisplay = GetStyleDisplay(); @@ -2751,16 +2747,13 @@ nsBlockFrame::AttributeChanged(nsIPresContext* aPresContext, // XXX Not sure if this is necessary anymore blockParent->RenumberLists(aPresContext); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, blockParent, eReflowType_ContentChanged, nsnull, aAttribute); if (NS_SUCCEEDED(rv)) - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } } } @@ -4559,8 +4552,7 @@ nsBlockFrame::AddFrames(nsIPresContext* aPresContext, return NS_OK; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); // Attempt to find the line that contains the previous sibling nsLineList::iterator prevSibLine = end_lines(); @@ -4735,9 +4727,8 @@ nsBlockFrame::DoRemoveOutOfFlowFrame(nsIPresContext* aPresContext, nsBlockFrame* block = (nsBlockFrame*)parent; // Remove aFrame from the appropriate list. if (display->IsAbsolutelyPositioned()) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - block->mAbsoluteContainer.RemoveFrame(block, aPresContext, *presShell, + block->mAbsoluteContainer.RemoveFrame(block, aPresContext, + *(aPresContext->PresShell()), block->mAbsoluteContainer.GetChildListName(), aFrame); } else { @@ -4756,8 +4747,7 @@ nsBlockFrame::DoRemoveFrame(nsIPresContext* aPresContext, return NS_OK; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); // Find the line and the previous sibling that contains // deletedFrame; we also find the pointer to the line. @@ -5285,9 +5275,7 @@ nsBlockFrame::Paint(nsIPresContext* aPresContext, } PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) return NS_OK; @@ -5575,9 +5563,9 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext, { nsresult result; - nsCOMPtr shell; + nsIPresShell *shell = nsnull; if (aEvent->message == NS_MOUSE_MOVE) { - aPresContext->GetShell(getter_AddRefs(shell)); + shell = aPresContext->GetPresShell(); if (!shell) return NS_OK; nsCOMPtr frameSelection; @@ -5605,7 +5593,7 @@ nsBlockFrame::HandleEvent(nsIPresContext* aPresContext, nsIFrame *resultFrame = nsnull;//this will be passed the handle event when we //can tell who to pass it to nsIFrame *mainframe = this; - aPresContext->GetShell(getter_AddRefs(shell)); + shell = aPresContext->GetPresShell(); if (!shell) return NS_OK; nsCOMPtr tracker( do_QueryInterface(shell, &result) ); @@ -5998,9 +5986,7 @@ nsBlockFrame::SetInitialChildList(nsIPresContext* aPresContext, nsRefPtr kidSC = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoElement, mStyleContext); // Create bullet frame - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - mBullet = new (shell.get()) nsBulletFrame; + mBullet = new (aPresContext->PresShell()) nsBulletFrame; if (nsnull == mBullet) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 62ea2819d40..972d46ebf4c 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -182,20 +182,14 @@ nsBlockReflowState::NewLineBox(nsIFrame* aFrame, PRInt32 aCount, PRBool aIsBlock) { - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - - return NS_NewLineBox(shell, aFrame, aCount, aIsBlock); + return NS_NewLineBox(mPresContext->PresShell(), aFrame, aCount, aIsBlock); } void nsBlockReflowState::FreeLineBox(nsLineBox* aLine) { if (aLine) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - - aLine->Destroy(presShell); + aLine->Destroy(mPresContext->PresShell()); } } @@ -945,10 +939,8 @@ nsBlockReflowState::FlowAndPlaceFloat(nsFloatCache* aFloatCache, if (prevInFlow) { prevRect = prevInFlow->GetRect(); - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + mPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsIFrame *placeParentPrev, *prevPlace; // If prevInFlow's placeholder is in a block that wasn't continued, we need to adjust diff --git a/mozilla/layout/html/base/src/nsBulletFrame.cpp b/mozilla/layout/html/base/src/nsBulletFrame.cpp index 23e4ab19a52..9e22f338e59 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.cpp +++ b/mozilla/layout/html/base/src/nsBulletFrame.cpp @@ -1692,9 +1692,8 @@ NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, // Now that the size is available (or an error occurred), trigger // a reflow of the bullet frame. - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { NS_ASSERTION(mParent, "No parent to pass the reflow request up to."); if (mParent) { // Reflow the first child of the parent not the bullet frame. @@ -1751,10 +1750,6 @@ NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest, #if 0 NS_ENSURE_TRUE(mPresContext, NS_ERROR_UNEXPECTED); // Why are we bothering? - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(aStatus)) { // We failed to load the image. Notify the pres shell if (NS_FAILED(aStatus) && (mImageRequest == aRequest || !mImageRequest)) { @@ -1794,8 +1789,7 @@ nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGr NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer"); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return; diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index dc3a3076c6f..677fcc78fab 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -591,10 +591,8 @@ SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, viewHasTransparentContent = PR_FALSE; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr doc; - shell->GetDocument(getter_AddRefs(doc)); + aPresContext->PresShell()->GetDocument(getter_AddRefs(doc)); if (doc) { nsIContent *rootElem = doc->GetRootContent(); if (!doc->GetParentDocument() && @@ -1126,8 +1124,7 @@ nsIFrame* nsContainerFrame::GetOverflowFrames(nsIPresContext* aPresContext, PRBool aRemoveProperty) const { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -1167,10 +1164,9 @@ nsresult nsContainerFrame::SetOverflowFrames(nsIPresContext* aPresContext, nsIFrame* aOverflowFrames) { - nsCOMPtr presShell; nsresult rv = NS_ERROR_FAILURE; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index ab626529da5..dad87ba4c4c 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -220,8 +220,7 @@ nsIFrameDebug::RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aI if((nsnull == aPresContext) || (nsnull == out)) return; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (nsnull != shell) { nsIFrame* frame; shell->GetRootFrame(&frame); @@ -612,8 +611,7 @@ nsFrame::ReplaceFrame(nsIPresContext* aPresContext, NS_IMETHODIMP nsFrame::Destroy(nsIPresContext* aPresContext) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); // Get the view pointer now before the frame properties disappear // when we call NotifyDestroyingFrame() @@ -826,10 +824,7 @@ nsFrame::Paint(nsIPresContext* aPresContext, return NS_OK; nsresult result; - nsCOMPtr shell; - result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; + nsIPresShell *shell = aPresContext->PresShell(); PRInt16 displaySelection = nsISelectionDisplay::DISPLAY_ALL; if (!(aFlags & nsISelectionDisplay::DISPLAY_IMAGES)) @@ -975,24 +970,19 @@ nsFrame::HandleEvent(nsIPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); switch (aEvent->message) { case NS_MOUSE_MOVE: { - if (NS_SUCCEEDED(rv)) - rv = HandleDrag(aPresContext, aEvent, aEventStatus); + HandleDrag(aPresContext, aEvent, aEventStatus); }break; case NS_MOUSE_LEFT_BUTTON_DOWN: { - if (NS_SUCCEEDED(rv)) - HandlePress(aPresContext, aEvent, aEventStatus); + HandlePress(aPresContext, aEvent, aEventStatus); }break; case NS_MOUSE_LEFT_BUTTON_UP: { - if (NS_SUCCEEDED(rv)) - HandleRelease(aPresContext, aEvent, aEventStatus); + HandleRelease(aPresContext, aEvent, aEventStatus); } break; default: break; @@ -1216,15 +1206,13 @@ ContentContainsPoint(nsIPresContext *aPresContext, nsPoint *aPoint, nsIView *aRelativeView) { - nsCOMPtr presShell; + nsIPresShell *presShell = aPresContext->GetPresShell(); - nsresult rv = aPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(rv) || !presShell) return PR_FALSE; + if (!presShell) return PR_FALSE; nsIFrame *frame = nsnull; - rv = presShell->GetPrimaryFrameFor(aContent, &frame); + nsresult rv = presShell->GetPrimaryFrameFor(aContent, &frame); if (NS_FAILED(rv) || !frame) return PR_FALSE; @@ -1312,8 +1300,7 @@ nsFrame::HandlePress(nsIPresContext* aPresContext, return NS_OK; nsresult rv; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; @@ -1688,12 +1675,11 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, nsIPresContext* aPresContext, PRBool aJumpLines) { - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr selcon; - if (NS_SUCCEEDED(rv)) - rv = GetSelectionController(aPresContext, getter_AddRefs(selcon)); + nsresult rv = GetSelectionController(aPresContext, getter_AddRefs(selcon)); if (NS_FAILED(rv)) return rv; + + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell || !selcon) return NS_ERROR_NOT_INITIALIZED; @@ -1759,7 +1745,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, nsCOMPtr frameselection = do_QueryInterface(selcon); //this MAY implement if (!frameselection) { - rv = aPresContext->GetPresShell()->GetFrameSelection(getter_AddRefs(frameselection)); + rv = aPresContext->PresShell()->GetFrameSelection(getter_AddRefs(frameselection)); if (NS_FAILED(rv) || !frameselection) return NS_OK; // return NS_OK; we don't care if this fails } @@ -1778,19 +1764,13 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext* aPresContext, if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) { return NS_OK; } - nsresult result; - - nsCOMPtr presShell; - - result = aPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(result)) - return result; + nsIPresShell *presShell = aPresContext->PresShell(); nsCOMPtr frameselection; nsCOMPtr selCon; - result = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult result = GetSelectionController(aPresContext, + getter_AddRefs(selCon)); if (NS_SUCCEEDED(result) && selCon) { frameselection = do_QueryInterface(selCon); //this MAY implement @@ -1845,14 +1825,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext* aPresContext, if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) return NS_OK; - nsresult result; - - nsCOMPtr presShell; - - result = aPresContext->GetShell(getter_AddRefs(presShell)); - - if (NS_FAILED(result)) - return result; + nsIPresShell *presShell = aPresContext->GetPresShell(); if (!presShell) return NS_ERROR_FAILURE; @@ -1860,7 +1833,8 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext* aPresContext, nsCOMPtr frameselection; nsCOMPtr selCon; - result = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult result = GetSelectionController(aPresContext, + getter_AddRefs(selCon)); if (NS_SUCCEEDED(result) && selCon) frameselection = do_QueryInterface(selCon); //this MAY implement @@ -2262,12 +2236,12 @@ nsFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = aPresContext->GetPresShell(); + + if (shell) { nsHTMLReflowCommand* reflowCmd; - rv = NS_NewHTMLReflowCommand(&reflowCmd, this, - eReflowType_ContentChanged); + rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ContentChanged); if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); } @@ -2546,8 +2520,7 @@ nsFrame::Invalidate(nsIPresContext* aPresContext, if (aPresContext) { // Don't allow invalidates to do anything when // painting is suppressed. - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { PRBool suppressed = PR_FALSE; shell->IsPaintingSuppressed(&suppressed); @@ -2802,9 +2775,8 @@ nsFrame::GetSelectionForVisCheck(nsIPresContext * aPresContext, nsISelection** a // we could be a container so check to see if we are in the selection range // this is a expensive if (!isSelected) { - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr selcon(do_QueryInterface(shell)); if (selcon) { rv = selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); @@ -2872,8 +2844,8 @@ nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionContro tmp = tmp->GetParent(); } } - nsCOMPtr shell; - if (NS_SUCCEEDED(aPresContext->GetShell(getter_AddRefs(shell))) && shell) + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr selCon = do_QueryInterface(shell); NS_IF_ADDREF(*aSelCon = selCon); @@ -3257,8 +3229,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext, //special check. if we allow non-text selection then we can allow a hit location to fall before a table. //otherwise there is no way to get and click signal to fall before a table (it being a line iterator itself) PRInt16 isEditor = 0; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; shell->GetSelectionFlags ( &isEditor ); @@ -3709,8 +3680,7 @@ nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos) { //if we are searching for a frame that is not in flow we will not find it. //we must instead look for its placeholder - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { @@ -4265,8 +4235,7 @@ nsFrame::GetOverflowAreaProperty(nsIPresContext* aPresContext, if (!((GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) || aCreateIfNecessary)) { return nsnull; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -4313,8 +4282,7 @@ nsFrame::StoreOverflow(nsIPresContext* aPresContext, else { if (mState & NS_FRAME_OUTSIDE_CHILDREN) { // remove the previously stored overflow area - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -4381,10 +4349,8 @@ GetIBSpecialSibling(nsIPresContext* aPresContext, * property, which is only set on the anonymous block frames we're * interested in. */ - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsIFrame *specialSibling; nsresult rv = frameManager->GetFrameProperty(aFrame, @@ -4509,10 +4475,8 @@ nsFrame::DoGetParentStyleContextFrame(nsIPresContext* aPresContext, // For out-of-flow frames, we must resolve underneath the // placeholder's parent. - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsIFrame *placeholder; frameManager->GetPlaceholderFrameFor(this, &placeholder); if (!placeholder) { @@ -4640,10 +4604,9 @@ nsFrame::SetProperty(nsIPresContext* aPresContext, void* aPropValue, NSFramePropertyDtorFunc aPropDtorFunc) { - nsCOMPtr presShell; nsresult rv = NS_ERROR_FAILURE; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -4662,8 +4625,7 @@ nsFrame::GetProperty(nsIPresContext* aPresContext, { void* value = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -4710,8 +4672,7 @@ NS_IMETHODIMP nsFrame::GetBidiProperty(nsIPresContext* aPresContext, memset(aPropertyValue, 0, aSize); void* val = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell) ); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -4738,8 +4699,7 @@ NS_IMETHODIMP nsFrame::SetBidiProperty(nsIPresContext* aPresContext, { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell) ); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager) ); diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index 769afedfd50..6c74c18ba0e 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -359,8 +359,7 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext, } } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); nsCOMPtr document; if (shell) shell->GetDocument(getter_AddRefs(document)); @@ -1053,8 +1052,7 @@ nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext, ScrollbarChanged(mOuter->mPresContext, x*mOnePixel, y*mOnePixel, isSmooth ? NS_VMREFRESH_SMOOTHSCROLL : 0); // Fire the onScroll event now that we have scrolled - nsCOMPtr presShell; - mOuter->mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mOuter->mPresContext->GetPresShell(); if (presShell) { nsScrollbarEvent event; event.eventStructType = NS_SCROLLBAR_EVENT; @@ -1620,11 +1618,10 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState) nsIFrame* child; if (NS_SUCCEEDED(parentFrame->FirstChild(mOuter->mPresContext, nsLayoutAtoms::fixedList, &child)) && child) { - nsCOMPtr presShell; - mOuter->mPresContext->GetShell(getter_AddRefs(presShell)); // force a reflow of the fixed children - nsFrame::CreateAndPostReflowCommand(presShell, parentFrame, + nsFrame::CreateAndPostReflowCommand(mOuter->mPresContext->PresShell(), + parentFrame, eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList); } } diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index 3b36c2cabbf..cde0cc8dd06 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -323,13 +323,8 @@ nsHTMLContainerFrame::CreateNextInFlow(nsIPresContext* aPresContext, // into our lines child list. nsIFrame* nextFrame = aFrame->GetNextSibling(); - nsIPresShell* presShell; - nsIStyleSet* styleSet; - aPresContext->GetShell(&presShell); - presShell->GetStyleSet(&styleSet); - NS_RELEASE(presShell); - styleSet->CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow); - NS_RELEASE(styleSet); + aPresContext->PresShell()->GetStyleSet()-> + CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow); if (nsnull == nextInFlow) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index 6cf463af7e3..ddc58db8608 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -382,9 +382,7 @@ CanvasFrame::Paint(nsIPresContext* aPresContext, // and frame construction. If painting is locked down, then we // do not paint our children. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) { if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { PaintSelf(aPresContext, aRenderingContext, aDirtyRect); diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index 439314a4ac4..c2b82dc870c 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -938,10 +938,8 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext* aPresContext, // Get the placeholder frame nsIFrame* placeholderFrame; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetPlaceholderFrameFor(frame, &placeholderFrame); + aPresContext->PresShell()->GetPlaceholderFrameFor(frame, &placeholderFrame); NS_ASSERTION(nsnull != placeholderFrame, "no placeholder frame"); // Find the nearest containing block frame to the placeholder frame, diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 42291352f4e..338dc5ebdc7 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -323,14 +323,10 @@ nsImageFrame::Init(nsIPresContext* aPresContext, } if (currentLoadStatus & imgIRequest::STATUS_ERROR) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - NS_ASSERTION(presShell, "Must have a pres shell!"); - PRBool loadBlocked = PR_FALSE; imageLoader->GetImageBlocked(&loadBlocked); rv = HandleLoadError(loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE, - presShell); + mPresContext->PresShell()); } // If we already have an image container, OnStartContainer won't be called // Set the animation mode here @@ -565,8 +561,7 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) // Now we need to reflow if we have an unconstrained size and have // already gotten the initial reflow if (!(mState & IMAGE_SIZECONSTRAINED) && (mState & IMAGE_GOTINITIALREFLOW)) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); NS_ASSERTION(mParent, "No parent to pass the reflow request up to."); NS_ASSERTION(presShell, "No PresShell."); if (mParent && presShell) { @@ -639,8 +634,7 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest, { NS_ENSURE_TRUE(mPresContext, NS_ERROR_UNEXPECTED); // why are we bothering? - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); NS_ASSERTION(presShell, "No PresShell."); // handle iconLoads first... @@ -848,10 +842,8 @@ nsImageFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); mState |= NS_FRAME_IS_DIRTY; - return mParent->ReflowDirtyChild(shell, this); + return mParent->ReflowDirtyChild(aPresContext->PresShell(), this); } // get the offset into the content area of the image where aImg starts if it is a continuation. @@ -1234,9 +1226,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, // If painting is suppressed, we need to stop image painting. We // have to cover here because of input image controls. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) { return NS_OK; } @@ -1399,11 +1389,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext, PRInt16 displaySelection = 0; nsresult result; - nsCOMPtr shell; - result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; - result = shell->GetSelectionFlags(&displaySelection); + result = aPresContext->PresShell()->GetSelectionFlags(&displaySelection); if (NS_FAILED(result)) return result; if (!(displaySelection & nsISelectionDisplay::DISPLAY_IMAGES)) @@ -1479,13 +1465,10 @@ nsImageFrame::GetImageMap(nsIPresContext* aPresContext) nsCOMPtr map; if (NS_SUCCEEDED(nsImageMapUtils::FindImageMap(doc,usemap,getter_AddRefs(map))) && map) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - mImageMap = new nsImageMap(); if (mImageMap) { NS_ADDREF(mImageMap); - mImageMap->Init(presShell, this, map); + mImageMap->Init(aPresContext->PresShell(), this, map); } } } @@ -1510,12 +1493,15 @@ nsImageFrame::TriggerLink(nsIPresContext* aPresContext, nsCOMPtr securityManager = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); - nsCOMPtr ps; - if (NS_SUCCEEDED(rv)) - rv = aPresContext->GetShell(getter_AddRefs(ps)); + if (NS_FAILED(rv)) + return; + + nsIPresShell *ps = aPresContext->GetPresShell(); + if (!ps) + return; + nsCOMPtr doc; - if (NS_SUCCEEDED(rv) && ps) - rv = ps->GetDocument(getter_AddRefs(doc)); + rv = ps->GetDocument(getter_AddRefs(doc)); if (NS_SUCCEEDED(rv)) { nsIURI *baseURI = doc ? doc->GetDocumentURL() : nsnull; @@ -1778,10 +1764,8 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext, // XXXldb Shouldn't width and height be handled by attribute mapping? if (nsHTMLAtoms::width == aAttribute || nsHTMLAtoms::height == aAttribute || nsHTMLAtoms::alt == aAttribute) { // XXX: could check for new width == old width, and make that a no-op - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); mState |= NS_FRAME_IS_DIRTY; - mParent->ReflowDirtyChild(presShell, (nsIFrame*) this); + mParent->ReflowDirtyChild(aPresContext->PresShell(), (nsIFrame*) this); } return NS_OK; @@ -1907,8 +1891,7 @@ nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGro NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer"); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return; diff --git a/mozilla/layout/html/base/src/nsLeafFrame.cpp b/mozilla/layout/html/base/src/nsLeafFrame.cpp index 08dfbed874f..bf00ef6173e 100644 --- a/mozilla/layout/html/base/src/nsLeafFrame.cpp +++ b/mozilla/layout/html/base/src/nsLeafFrame.cpp @@ -112,8 +112,6 @@ nsLeafFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, nsISupports* aSubContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); mState |= NS_FRAME_IS_DIRTY; - return mParent->ReflowDirtyChild(shell, this); + return mParent->ReflowDirtyChild(aPresContext->PresShell(), this); } diff --git a/mozilla/layout/html/base/src/nsLineBox.cpp b/mozilla/layout/html/base/src/nsLineBox.cpp index 371bc352c8e..cc0ebf33878 100644 --- a/mozilla/layout/html/base/src/nsLineBox.cpp +++ b/mozilla/layout/html/base/src/nsLineBox.cpp @@ -303,8 +303,7 @@ nsLineBox::DeleteLineList(nsIPresContext* aPresContext, nsLineList& aLines) child = nextChild; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); do { nsLineBox* line = aLines.front(); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 8da7151dab6..bdc62142425 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -644,10 +644,8 @@ nsObjectFrame::Init(nsIPresContext* aPresContext, imageLoader->ImageURIChanged(data); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame * aNewFrame = nsnull; - rv = NS_NewImageFrame(shell, &aNewFrame); + rv = NS_NewImageFrame(aPresContext->PresShell(), &aNewFrame); if (NS_FAILED(rv)) return rv; @@ -677,10 +675,8 @@ nsObjectFrame::Init(nsIPresContext* aPresContext, if(bDoc) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame * aNewFrame = nsnull; - rv = NS_NewHTMLFrameOuterFrame(shell, &aNewFrame); + rv = NS_NewHTMLFrameOuterFrame(aPresContext->PresShell(), &aNewFrame); if(NS_FAILED(rv)) return rv; @@ -1187,10 +1183,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, text->mVerticalAlign.SetNormalValue(); //check for alternative content with CantRenderReplacedElement() - nsIPresShell* presShell; - aPresContext->GetShell(&presShell); - rv = presShell->CantRenderReplacedElement(this); - NS_RELEASE(presShell); + rv = aPresContext->PresShell()->CantRenderReplacedElement(this); } else { NotifyContentObjectWrapper(); } @@ -1287,12 +1280,8 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext, nsCOMPtr element = do_QueryInterface(mContent, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) return rv; - nsCOMPtr document; - rv = shell->GetDocument(getter_AddRefs(document)); + rv = aPresContext->PresShell()->GetDocument(getter_AddRefs(document)); if (NS_FAILED(rv)) return rv; if (! document) @@ -1438,9 +1427,9 @@ nsObjectFrame::ContentChanged(nsIPresContext* aPresContext, nsISupports* aSubContent) { // Generate a reflow command with this frame as the target frame - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsHTMLReflowCommand* reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ContentChanged); @@ -2418,8 +2407,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument) { nsresult rv = NS_ERROR_FAILURE; if (nsnull != mContext) { - nsCOMPtr shell; - mContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mContext->GetPresShell(); if (shell) rv = shell->GetDocument(aDocument); } @@ -2617,11 +2605,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result) return NS_ERROR_FAILURE; } - nsCOMPtr shell; - mContext->GetShell(getter_AddRefs(shell)); - nsCOMPtr doc; - shell->GetDocument(getter_AddRefs(doc)); + mContext->PresShell()->GetDocument(getter_AddRefs(doc)); rv = doc->GetBaseURL()->GetSpec(mDocumentBase); } diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 92edb33ebfd..a80ba820b77 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -163,12 +163,10 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext, nsIFrame* prevLastChild = prevContentPage->mFrames.LastChild(); // Create a continuing child of the previous page's last child - nsCOMPtr presShell; nsCOMPtr styleSet; nsIFrame* newFrame; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetStyleSet(getter_AddRefs(styleSet)); + aPresContext->PresShell()->GetStyleSet(getter_AddRefs(styleSet)); styleSet->CreateContinuingFrame(aPresContext, prevLastChild, contentPage, &newFrame); // Make the new area frame the 1st child of the page content frame. There may already be // children placeholders which don't get reflowed but must not be destroyed until the diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index bd46d2724bb..17e4ca943c2 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -884,11 +884,8 @@ IncrementalReflow::Dispatch(nsIPresContext *aPresContext, nsReflowPath *path = NS_STATIC_CAST(nsReflowPath *, mRoots[i]); nsIFrame *first = path->mFrame; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsIFrame* root; - shell->GetRootFrame(&root); + aPresContext->PresShell()->GetRootFrame(&root); first->WillReflow(aPresContext); nsContainerFrame::PositionFrameView(aPresContext, first); @@ -6879,20 +6876,16 @@ CompareTrees(nsIPresContext* aFirstPresContext, nsIFrame* aFirstFrame, // verify that neither frame has a space manager, // or they both do and the space managers are equivalent nsCOMPtrfm1; - nsCOMPtr ps1; nsSpaceManager *sm1; - aFirstPresContext->GetShell(getter_AddRefs(ps1)); - NS_ASSERTION(ps1, "no pres shell for primary tree!"); + nsIPresShell *ps1 = aFirstPresContext->PresShell(); ps1->GetFrameManager(getter_AddRefs(fm1)); NS_ASSERTION(fm1, "no frame manager for primary tree!"); fm1->GetFrameProperty((nsIFrame*)k1, nsLayoutAtoms::spaceManagerProperty, 0, (void **)&sm1); // look at the test frame nsCOMPtrfm2; - nsCOMPtr ps2; nsSpaceManager *sm2; - aSecondPresContext->GetShell(getter_AddRefs(ps2)); - NS_ASSERTION(ps2, "no pres shell for test tree!"); + nsIPresShell *ps2 = aSecondPresContext->PresShell(); ps2->GetFrameManager(getter_AddRefs(fm2)); NS_ASSERTION(fm2, "no frame manager for test tree!"); fm2->GetFrameProperty((nsIFrame*)k2, nsLayoutAtoms::spaceManagerProperty, diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index 34400d27531..7025b95cbe3 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -203,17 +203,9 @@ nsSimplePageSequenceFrame::CreateContinuingPageFrame(nsIPresContext* aPresContex nsIFrame* aPageFrame, nsIFrame** aContinuingPage) { - nsIPresShell* presShell; - nsIStyleSet* styleSet; - nsresult rv; - // Create the continuing frame - aPresContext->GetShell(&presShell); - presShell->GetStyleSet(&styleSet); - NS_RELEASE(presShell); - rv = styleSet->CreateContinuingFrame(aPresContext, aPageFrame, this, aContinuingPage); - NS_RELEASE(styleSet); - return rv; + return aPresContext->PresShell()->GetStyleSet()-> + CreateContinuingFrame(aPresContext, aPageFrame, this, aContinuingPage); } void diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index f4924b0c093..764a51af86d 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -1335,7 +1335,7 @@ nsTextFrame::GetDocument(nsIPresContext* aPresContext) NS_IF_ADDREF(result = mContent->GetDocument()); } if (!result && aPresContext) { - aPresContext->GetPresShell()->GetDocument(&result); + aPresContext->PresShell()->GetDocument(&result); } return result; } @@ -1402,15 +1402,13 @@ nsTextFrame::ContentChanged(nsIPresContext* aPresContext, } // Ask the parent frame to reflow me. - nsresult rv; - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell && mParent) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell && mParent) { mParent->ReflowDirtyChild(shell, targetTextFrame); } - return rv; + return NS_OK; } NS_IMETHODIMP @@ -2014,12 +2012,12 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsIPresContext* aPresConte NS_ENSURE_ARG_POINTER(aLineBreaker); //get the presshell - nsresult rv = aPresContext->GetShell(aPresShell); - if (NS_FAILED(rv) || (*aPresShell) == nsnull) + NS_IF_ADDREF(*aPresShell = aPresContext->GetPresShell()); + if (!*aPresShell) return NS_ERROR_FAILURE; //get the selection controller - rv = GetSelectionController(aPresContext, aSelectionController); + nsresult rv = GetSelectionController(aPresContext, aSelectionController); if (NS_FAILED(rv) || !(*aSelectionController)) return NS_ERROR_FAILURE; @@ -3376,11 +3374,10 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, // initialize out param *aNewContent = nsnull; - nsCOMPtr shell; - nsresult rv = aCX->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aCX->GetPresShell(); + if (shell) { nsCOMPtr acx; - rv = shell->CreateRenderingContext(this, getter_AddRefs(acx)); + nsresult rv = shell->CreateRenderingContext(this, getter_AddRefs(acx)); if (NS_SUCCEEDED(rv)) { TextStyle ts(aCX, *acx, mStyleContext); if (ts.mSmallCaps || ts.mWordSpacing || ts.mLetterSpacing || ts.mJustifying) { @@ -3632,13 +3629,13 @@ nsTextFrame::SetSelected(nsIPresContext* aPresContext, else {//we need to see if any other selection available. SelectionDetails *details = nsnull; - nsCOMPtr shell; nsCOMPtr frameSelection; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell){ + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr selCon; - rv = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult rv = GetSelectionController(aPresContext, + getter_AddRefs(selCon)); if (NS_SUCCEEDED(rv) && selCon) { frameSelection = do_QueryInterface(selCon); //this MAY implement @@ -4383,10 +4380,7 @@ nsTextFrame::CheckVisibility(nsIPresContext* aContext, PRInt32 aStartIndex, PRIn if (aStartIndex < (mContentOffset + mContentLength)) { //get the presshell - nsCOMPtr shell; - rv = aContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) - return rv; + nsIPresShell *shell = aContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 1c57c0be359..da87746954a 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -374,8 +374,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, // will have been set by nsCSSFrameConstructor if necessary. nsCOMPtr contentParentAtom = do_GetAtom("contentParent"); nsIFrame* contentParent = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; @@ -402,9 +401,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext, view->CreateWidget(kCChildCID); } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsIFrame* firstChild = new (shell.get()) nsHTMLFrameInnerFrame; + nsIFrame* firstChild = new (aPresContext->PresShell()) nsHTMLFrameInnerFrame; if (firstChild) { mFrames.SetFrames(firstChild); // Resolve the style context for the inner frame diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 924772f70e2..8a8da925447 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -349,8 +349,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, viewMan->InsertChild(parView, view, nsnull, PR_TRUE); SetView(view); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsFrameborder frameborder = GetFrameBorder(); PRInt32 borderWidth = GetBorderWidth(aPresContext, PR_FALSE); @@ -444,7 +443,7 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext, for (int blankX = mChildCount; blankX < numCells; blankX++) { // XXX the blank frame is using the content of its parent - at some point it // should just have null content, if we support that - nsHTMLFramesetBlankFrame* blankFrame = new (shell.get()) nsHTMLFramesetBlankFrame; + nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame; nsRefPtr pseudoStyleContext; pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(nsnull, nsCSSAnonBoxes::framesetBlank, @@ -979,9 +978,8 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, { DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - + nsIPresShell *shell = aPresContext->PresShell(); + //printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight); // Always get the size so that the caller knows how big we are GetDesiredSize(aPresContext, aReflowState, aDesiredSize); @@ -1071,7 +1069,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, offset.x = 0; offset.y += lastSize.height; if (firstTime) { // create horizontal border - borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_FALSE, PR_FALSE); + borderFrame = new (shell) nsHTMLFramesetBorderFrame(borderWidth, + PR_FALSE, + PR_FALSE); nsRefPtr pseudoStyleContext; pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::horizontalFramesetBorder, @@ -1098,7 +1098,9 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext, if (cellIndex.x > 0) { // moved to next col in same row if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border - borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_TRUE, PR_FALSE); + borderFrame = new (shell) nsHTMLFramesetBorderFrame(borderWidth, + PR_TRUE, + PR_FALSE); nsRefPtr pseudoStyleContext; pseudoStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, nsCSSPseudoElements::verticalFramesetBorder, diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 6bda6ffbdbb..884bb623dbb 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -544,8 +544,7 @@ void nsComboboxControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); @@ -587,10 +586,9 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) event.clickCount = 0; event.widget = nsnull; - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) - rv = shell->HandleDOMEventWithTarget(mContent, &event, &status); + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) + shell->HandleDOMEventWithTarget(mContent, &event, &status); } // Show the dropdown list @@ -624,9 +622,7 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList) mDroppedDown = PR_FALSE; } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->FlushPendingNotifications(PR_FALSE); + aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); if (widget) widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList); @@ -696,14 +692,12 @@ nsComboboxControlFrame::SetChildFrameSize(nsIFrame* aFrame, nscoord aWidth, nsco nsresult nsComboboxControlFrame::GetPrimaryComboFrame(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame** aFrame) { - nsresult rv = NS_OK; // Get the primary frame from the presentation shell. - nsCOMPtr presShell; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_SUCCEEDED(rv) && presShell) { + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (presShell) { presShell->GetPrimaryFrameFor(aContent, aFrame); } - return rv; + return NS_OK; } nsresult @@ -1841,13 +1835,9 @@ nsComboboxControlFrame::RedisplayText(PRInt32 aIndex) rv = ActuallyDisplayText(textToDisplay, PR_TRUE); //mTextFrame->AddStateBits(NS_FRAME_IS_DIRTY); mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY); - nsCOMPtr shell; - rv = mPresContext->GetShell(getter_AddRefs(shell)); - ReflowDirtyChild(shell, (nsIFrame*) mDisplayFrame); + ReflowDirtyChild(mPresContext->PresShell(), mDisplayFrame); -// nsCOMPtr presShell; -// mPresContext->GetShell(getter_AddRefs(presShell)); -// presShell->FlushPendingNotifications(PR_FALSE); +// mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } } return rv; @@ -2049,8 +2039,7 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) return NS_OK; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); if (NS_FAILED(rv)) { return rv; } if (!mDisplayFrame) { return NS_ERROR_NULL_POINTER; } @@ -2072,9 +2061,7 @@ nsComboboxControlFrame::CreateDisplayFrame(nsIPresContext* aPresContext) nsCOMPtr content(do_QueryInterface(mDisplayContent)); mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); mTextFrame->SetInitialChildList(aPresContext, nsnull, nsnull); - nsCOMPtr presShell; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_FAILED(rv)) { return rv; } + nsIPresShell *presShell = aPresContext->GetPresShell(); if (!presShell) { return NS_ERROR_NULL_POINTER; } nsCOMPtr frameManager; rv = presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -2180,8 +2167,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIPresContext* aPresContext, nsCOMPtr content(do_QueryInterface(mDisplayContent)); if (aContent == content.get()) { // Get PresShell - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); // Start by by creating a containing frame nsresult rv = NS_NewBlockFrame(shell, (nsIFrame**)&mDisplayFrame, NS_BLOCK_SPACE_MGR); diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index 350750fac0f..c0aae057c64 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -234,8 +234,7 @@ void nsFileControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index 45b8389fc94..00c69c2e1ba 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -632,8 +632,7 @@ void nsFormControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index 65ac8e29527..d3e6c794136 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -507,14 +507,11 @@ void nsFormControlHelper::StyleChangeReflow(nsIPresContext* aPresContext, nsIFrame* aFrame) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand* reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, eReflowType_StyleChanged); if (NS_SUCCEEDED(rv)) { - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } } diff --git a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp index 995de696671..4e0ea271123 100644 --- a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -231,13 +231,10 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext, nsCOMPtr content(do_QueryInterface(mTextContent)); if (aContent == content.get()) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsIFrame * parentFrame = mFrames.FirstChild(); nsStyleContext* styleContext = parentFrame->GetStyleContext(); - rv = NS_NewTextFrame(shell, &newFrame); + rv = NS_NewTextFrame(aPresContext->PresShell(), &newFrame); if (NS_FAILED(rv)) { return rv; } if (!newFrame) { return NS_ERROR_NULL_POINTER; } nsRefPtr textStyleContext; diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index 7cd540dc222..8322a1f48c0 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -136,10 +136,8 @@ nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext, flags |= NS_BLOCK_SHRINK_WRAP; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* areaFrame; - NS_NewAreaFrame(shell, &areaFrame, flags); + NS_NewAreaFrame(aPresContext->PresShell(), &areaFrame, flags); mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame @@ -271,8 +269,7 @@ void nsHTMLButtonControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp index 4e21fdfcd1a..d83f6fedc63 100644 --- a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp @@ -358,8 +358,7 @@ void nsImageControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp index efaf6f0ecf6..7a08b537dfe 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp @@ -173,8 +173,7 @@ NS_IMETHODIMP nsIsIndexFrame::GetInputFrame(nsIPresContext* aPresContext, nsIFormControlFrame** oFrame) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (!mInputContent) NS_WARNING("null content - cannot restore state"); if (presShell && mInputContent) { nsIFrame *frame; @@ -315,8 +314,7 @@ void nsIsIndexFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 1b66a10b285..4e840a25bc3 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -472,9 +472,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext, // Don't allow painting of list controls when painting is suppressed. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) return NS_OK; @@ -492,10 +490,8 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext, // if we aren't selected in the mState we could be a container // so check to see if we are in the selection range if (!isSelected) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr selcon; - selcon = do_QueryInterface(shell); + selcon = do_QueryInterface(aPresContext->PresShell()); if (selcon) { nsCOMPtr selection; selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -551,8 +547,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer GetScrollableView(mPresContext, &scrollableView); if (!scrollableView) return; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (!presShell) return; nsIFrame* containerFrame; @@ -1151,9 +1146,8 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, nsIContent * option = GetOptionContent(0); if (option != nsnull) { nsIFrame * optFrame; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - nsresult result = presShell->GetPrimaryFrameFor(option, &optFrame); + nsresult result = mPresContext->PresShell()-> + GetPrimaryFrameFor(option, &optFrame); if (NS_SUCCEEDED(result) && optFrame != nsnull) { nsStyleContext* optStyle = optFrame->GetStyleContext(); if (optStyle) { @@ -2121,8 +2115,7 @@ void nsListControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); @@ -2458,8 +2451,7 @@ nsListControlFrame::FireOnChange() event.eventStructType = NS_EVENT; event.message = NS_FORM_CHANGE; - nsCOMPtr presShell; - rv = mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (presShell) { rv = presShell->HandleEventWithTarget(&event, this, nsnull, NS_EVENT_FLAG_INIT, &status); @@ -2875,10 +2867,8 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, nsCOMPtr node; mouseEvent->GetTarget(getter_AddRefs(node)); nsCOMPtr content = do_QueryInterface(node); - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); nsIFrame * frame; - nsresult result = presShell->GetPrimaryFrameFor(content, &frame); + mPresContext->PresShell()->GetPrimaryFrameFor(content, &frame); printf("Target Frame: %p this: %p\n", frame, this); printf("-->\n"); #endif @@ -3063,8 +3053,7 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement) } // otherwise we find the content's frame and scroll to it - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->PresShell(); nsIFrame * childframe; nsresult result; if (aOptElement) { @@ -3497,9 +3486,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) // Why aren't they getting flushed each time? // because this isn't needed for Gfx if (IsInDropDownMode() == PR_TRUE) { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - presShell->FlushPendingNotifications(PR_FALSE); + mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } REFLOW_DEBUG_MSG2(" After: %d\n", newIndex); diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index be6fc196642..5d5938eeec5 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -1635,11 +1635,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, mState |= NS_FRAME_INDEPENDENT_SELECTION; - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - - if (NS_FAILED(rv)) - return rv; + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; @@ -1647,7 +1643,7 @@ nsTextControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the DOM document nsCOMPtr doc; - rv = shell->GetDocument(getter_AddRefs(doc)); + nsresult rv = shell->GetDocument(getter_AddRefs(doc)); if (NS_FAILED(rv)) return rv; if (!doc) @@ -2104,8 +2100,7 @@ void nsTextControlFrame::SetFocus(PRBool aOn , PRBool aRepaint){} void nsTextControlFrame::ScrollIntoView(nsIPresContext* aPresContext) { if (aPresContext) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { presShell->ScrollFrameIntoView(this, NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); @@ -2685,10 +2680,9 @@ nsTextControlFrame::AttributeChanged(nsIPresContext* aPresContext, } else if (mEditor && nsHTMLAtoms::disabled == aAttribute) { - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) - return rv; + // XXXbryner do we need to check for a null presshell here? + // we don't do anything with it. + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return NS_ERROR_FAILURE; @@ -3068,11 +3062,8 @@ nsTextControlFrame::SetInitialChildList(nsIPresContext* aPresContext, // register the event listeners with the DOM event reveiver rv = erP->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *,mTextListener), NS_GET_IID(nsIDOMFocusListener)); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register focus listener"); - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(rv)) - return rv; - if (!shell) + // XXXbryner do we need to check for a null presshell here? + if (!aPresContext->GetPresShell()) return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 09b6528a6ef..a9042d59d15 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -779,7 +779,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon mFrameState(aHistoryState), mPseudoFrames() { - aPresContext->GetShell(getter_AddRefs(mPresShell)); + mPresShell = aPresContext->PresShell(); mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); } @@ -794,7 +794,7 @@ nsFrameConstructorState::nsFrameConstructorState(nsIPresContext* aPresCon mFirstLineStyle(PR_FALSE), mPseudoFrames() { - aPresContext->GetShell(getter_AddRefs(mPresShell)); + mPresShell = aPresContext->PresShell(); mPresShell->GetFrameManager(getter_AddRefs(mFrameManager)); nsCOMPtr container; aPresContext->GetContainer(getter_AddRefs(container)); @@ -1358,8 +1358,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex const nsStyleContentData &data = aStyleContent->ContentAt(aContentIndex); nsStyleContentType type = data.mType; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); if (eStyleContentType_URL == type) { // Create an HTML image content object, and set the SRC. @@ -4343,9 +4342,6 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel return rv; } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - // Initialize it nsIFrame* geometricParent = aParentFrame; @@ -4363,7 +4359,8 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel nsHTMLContainerFrame::CreateViewForFrame(newFrame, aParentFrame, PR_FALSE); nsIFrame* areaFrame; - NS_NewAreaFrame(shell, &areaFrame, NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP); + NS_NewAreaFrame(aPresContext->PresShell(), &areaFrame, + NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP); // Resolve style and initialize the frame nsRefPtr styleContext; @@ -7215,8 +7212,7 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchy(nsIPresContext* aPresConte #endif nsresult rv = NS_OK; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (mDocument && shell) { nsIContent *rootContent = mDocument->GetRootContent(); @@ -8008,7 +8004,7 @@ static nsresult InsertOutOfFlow(nsIPresContext* aPresContext, aFrameItems.containingBlock->GetContent()) < 0) { // lastChild comes before the new children, so insert after lastChild return aFrameItems.containingBlock-> - AppendFrames(aPresContext, *aPresContext->GetPresShell(), + AppendFrames(aPresContext, *(aPresContext->PresShell()), aChildListName, aFrameItems.childList); } } @@ -8027,7 +8023,7 @@ static nsresult InsertOutOfFlow(nsIPresContext* aPresContext, } return aFrameItems.containingBlock-> - InsertFrames(aPresContext, *aPresContext->GetPresShell(), + InsertFrames(aPresContext, *(aPresContext->PresShell()), aChildListName, insertionPoint, aFrameItems.childList); } @@ -8073,8 +8069,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); #ifdef MOZ_XUL if (aContainer) { @@ -8722,8 +8717,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsresult rv = NS_OK; #ifdef MOZ_XUL @@ -9275,8 +9269,7 @@ nsCSSFrameConstructor::RemoveMappingsForFrameSubtree(nsIPresContext* aPresContex nsIFrame* aRemovedFrame, nsILayoutHistoryState* aFrameState) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -9308,8 +9301,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsCOMPtr frameManager; shell->GetFrameManager(getter_AddRefs(frameManager)); nsresult rv = NS_OK; @@ -9710,8 +9702,7 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIViewManager* aViewManager, nsChangeHint aChange) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); PRBool isPaintingSuppressed = PR_FALSE; shell->IsPaintingSuppressed(&isPaintingSuppressed); if (isPaintingSuppressed) { @@ -9794,9 +9785,6 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, aFrame = GetIBContainingBlockFor(aFrame); // Target a style-change reflow at the frame. - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsHTMLReflowCommand *reflowCmd; rv = NS_NewHTMLReflowCommand(&reflowCmd, aFrame, eReflowType_StyleChanged, @@ -9804,7 +9792,7 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, aAttribute); if (NS_SUCCEEDED(rv)) - shell->AppendReflowCommand(reflowCmd); + aPresContext->PresShell()->AppendReflowCommand(reflowCmd); } return NS_OK; @@ -9815,13 +9803,11 @@ nsCSSFrameConstructor::ContentChanged(nsIPresContext* aPresContext, nsIContent* aContent, nsISupports* aSubContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsresult rv = NS_OK; // Find the child frame nsIFrame* frame; - shell->GetPrimaryFrameFor(aContent, &frame); + aPresContext->PresShell()->GetPrimaryFrameFor(aContent, &frame); // Notify the first frame that maps the content. It will generate a reflow // command @@ -9888,10 +9874,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, if (!count) return NS_OK; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); // Mark frames so that we skip frames that die along the way, bug 123049. // A frame can be in the list multiple times with different hints. Further @@ -9940,8 +9924,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, // reget from content since it may have been regenerated... if (content) { nsIFrame* frame; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); shell->GetPrimaryFrameFor(content, &frame); if (frame) { nsCOMPtr frameManager; @@ -9986,8 +9969,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, { nsresult result = NS_OK; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); NS_ASSERTION(shell, "couldn't get pres shell"); if (shell) { @@ -10135,8 +10117,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, nsCOMPtr kungFuDeathGrip(this); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); // Get the frame associated with the content which is the highest in the frame tree nsIFrame* primaryFrame; @@ -10441,8 +10422,7 @@ nsCSSFrameConstructor::CantRenderReplacedElement(nsIPresShell* aPresShell, // If the frame is out of the flow, then it has a placeholder frame. nsPlaceholderFrame* placeholderFrame = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); if (listName) { presShell->GetPlaceholderFrameFor(aFrame, (nsIFrame**)&placeholderFrame); } @@ -11183,10 +11163,6 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsIPresContext* aPresContext, *aFrame = nsnull; // initialize OUT parameter - // Get the pres shell - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - // We want to be able to quickly map from a content object to its frame, // but we also want to keep the hash table small. Therefore, many frames // are not added to the hash table when they're first created: @@ -11349,11 +11325,10 @@ nsCSSFrameConstructor::CaptureStateForFramesOf(nsIPresContext* aPresContext, nsIContent* aContent, nsILayoutHistoryState* aHistoryState) { - nsCOMPtr presShell; nsresult rv = NS_OK; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_SUCCEEDED(rv) && presShell) { + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (presShell) { nsIFrame* frame; rv = presShell->GetPrimaryFrameFor(aContent, &frame); if (NS_SUCCEEDED(rv) && frame) { @@ -11372,9 +11347,8 @@ nsCSSFrameConstructor::CaptureStateFor(nsIPresContext* aPresContext, nsresult rv = NS_OK; if (aFrame && aPresContext && aHistoryState) { - nsCOMPtr presShell; - rv = aPresContext->GetShell(getter_AddRefs(presShell)); - if (NS_SUCCEEDED(rv) && presShell) { + nsIPresShell *presShell = aPresContext->GetPresShell(); + if (presShell) { nsCOMPtr frameManager; rv = presShell->GetFrameManager(getter_AddRefs(frameManager)); if (NS_SUCCEEDED(rv) && frameManager) { @@ -11390,10 +11364,8 @@ nsCSSFrameConstructor::MaybeRecreateFramesForContent(nsIPresContext* aPresContex nsIContent* aContent) { nsresult result = NS_OK; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr frameManager; - shell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); nsStyleContext *oldContext = frameManager->GetUndisplayedContent(aContent); if (oldContext) { @@ -11424,8 +11396,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, // content (which would otherwise result in *two* nested reframe // containing block from ContentRemoved() and ContentInserted(), // below!) - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsIFrame* frame; shell->GetPrimaryFrameFor(aContent, &frame); @@ -12573,8 +12544,6 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, nsILayoutHistoryState* aFrameState) { #ifdef MOZ_XUL - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsresult rv = NS_OK; // Construct a new frame @@ -12600,7 +12569,8 @@ nsCSSFrameConstructor::CreateListBoxContent(nsIPresContext* aPresContext, PRInt32 namespaceID; aChild->GetNameSpaceID(&namespaceID); - rv = ConstructFrameInternal(shell, aPresContext, state, aChild, + rv = ConstructFrameInternal(aPresContext->PresShell(), + aPresContext, state, aChild, aParentFrame, aChild->Tag(), namespaceID, styleContext, frameItems, PR_FALSE); @@ -13087,8 +13057,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, nsCOMPtr presShell; nsCOMPtr frameManager; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetFrameManager(getter_AddRefs(frameManager)); + aPresContext->PresShell()->GetFrameManager(getter_AddRefs(frameManager)); // Destroy the frames. As we do make sure any content to frame mappings // or entries in the undisplayed content map are removed @@ -13243,8 +13212,7 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, if (! aBlockChildFrame) return NS_ERROR_NULL_POINTER; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); if (IsBlockFrame(aPresContext, aFrame)) { // If aFrame is a block frame, then we're done: make @@ -13415,10 +13383,8 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF } #endif - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); PRBool isReflowing; - shell->IsReflowLocked(&isReflowing); + aPresContext->PresShell()->IsReflowLocked(&isReflowing); if(isReflowing) { // don't ReframeContainingBlock, this will result in a crash // if we remove a tree that's in reflow - see bug 121368 for testcase diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index c7641825993..4953420de55 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -1547,8 +1547,7 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, NS_ASSERTION(aPresContext, "null params not allowed"); PRBool result = PR_FALSE; // assume we did not find the HTML element - nsIPresShell* shell = nsnull; - aPresContext->GetShell(&shell); + nsIPresShell* shell = aPresContext->GetPresShell(); if (shell) { nsIDocument *doc = nsnull; if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) { @@ -1582,7 +1581,6 @@ PRBool GetBGColorForHTMLElement( nsIPresContext *aPresContext, }// if content NS_RELEASE(doc); }// if doc - NS_RELEASE(shell); } // if shell return result; @@ -2688,10 +2686,9 @@ FindCanvasBackground(nsIPresContext* aPresContext, // and thus |InitialReflow| on the pres shell. See bug 119351 // for the ugly details. if (bodyContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame *bodyFrame; - nsresult rv = shell->GetPrimaryFrameFor(bodyContent, &bodyFrame); + nsresult rv = aPresContext->PresShell()-> + GetPrimaryFrameFor(bodyContent, &bodyFrame); if (NS_SUCCEEDED(rv) && bodyFrame) result = bodyFrame->GetStyleBackground(); } @@ -3080,12 +3077,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext, } else { // The viewport isn't scrollable, so use the root frame's view - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - NS_ASSERTION(presShell, "no pres shell"); - nsIFrame* rootFrame; - presShell->GetRootFrame(&rootFrame); + aPresContext->PresShell()->GetRootFrame(&rootFrame); NS_ASSERTION(rootFrame, "no root frame"); PRBool isPaginated = PR_FALSE; diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index c3c01d2f12b..b0472f5bb2e 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -332,12 +332,9 @@ nsTableCellFrame::DecorateForSelection(nsIPresContext* aPresContext, PRBool isSelected = (GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; if (isSelected) { - nsCOMPtr shell; - nsresult result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; nsCOMPtr frameSelection; - result = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + nsresult result = aPresContext->PresShell()-> + GetFrameSelection(getter_AddRefs(frameSelection)); if (NS_SUCCEEDED(result)) { PRBool tableCellSelectionMode; result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); @@ -536,12 +533,9 @@ nsTableCellFrame::SetSelected(nsIPresContext* aPresContext, // only this frame is considered nsFrame::SetSelected(aPresContext, aRange, aSelected, aSpread); - nsCOMPtr shell; - nsresult result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; nsCOMPtr frameSelection; - result = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + nsresult result = aPresContext->PresShell()-> + GetFrameSelection(getter_AddRefs(frameSelection)); if (NS_SUCCEEDED(result) && frameSelection) { PRBool tableCellSelectionMode; result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp index 8be89bcbf5e..48b366bf175 100644 --- a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp @@ -318,7 +318,7 @@ nsTableColGroupFrame::RemoveChild(nsIPresContext& aPresContext, // XXX this could be optimized with much effort tableFrame->SetNeedStrategyInit(PR_TRUE); // Generate a reflow command so we reflow the table - nsTableFrame::AppendDirtyReflowCommand(nsTableFrame::GetPresShellNoAddref(&aPresContext), tableFrame); + nsTableFrame::AppendDirtyReflowCommand(aPresContext.PresShell(), tableFrame); } // this removes children form the last col group (eColGroupAnonymousCell) in the diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index d682f7eed37..b2d20186eb2 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -382,18 +382,6 @@ nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame, return PR_FALSE; } -nsIPresShell* -nsTableFrame::GetPresShellNoAddref(nsIPresContext* aPresContext) -{ - nsIPresShell* tempShell; - nsIPresShell* presShell; - aPresContext->GetShell(&tempShell); - presShell = tempShell; - NS_RELEASE(tempShell); // presShell is needed because this sets tempShell to nsnull - - return presShell; -} - // XXX this needs to be cleaned up so that the frame constructor breaks out col group // frames into a separate child list. NS_IMETHODIMP @@ -490,7 +478,7 @@ void nsTableFrame::AttributeChangedFor(nsIPresContext* aPresContext, // XXX This could probably be optimized with some effort SetNeedStrategyInit(PR_TRUE); - AppendDirtyReflowCommand(GetPresShellNoAddref(aPresContext), this); + AppendDirtyReflowCommand(aPresContext->PresShell(), this); } } } @@ -837,9 +825,8 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext, mStyleContext); // Create a col group frame nsIFrame* newFrame; - nsCOMPtr presShell; - aPresContext.GetShell(getter_AddRefs(presShell)); - nsresult result = NS_NewTableColGroupFrame(presShell, &newFrame); + nsresult result = NS_NewTableColGroupFrame(aPresContext.PresShell(), + &newFrame); if (NS_SUCCEEDED(result) && newFrame) { ((nsTableColGroupFrame *)newFrame)->SetColType(aColGroupType); newFrame->Init(&aPresContext, colGroupContent, this, colGroupStyle, nsnull); @@ -953,9 +940,7 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, // create the new col frame nsIFrame* colFrame; - nsCOMPtr presShell; - aPresContext.GetShell(getter_AddRefs(presShell)); - NS_NewTableColFrame(presShell, &colFrame); + NS_NewTableColFrame(aPresContext.PresShell(), &colFrame); ((nsTableColFrame *) colFrame)->SetColType(aColType); colFrame->Init(&aPresContext, iContent, &aColGroupFrame, styleContext, nsnull); @@ -2636,7 +2621,7 @@ nsTableFrame::RemoveFrame(nsIPresContext* aPresContext, // XXX This could probably be optimized with much effort SetNeedStrategyInit(PR_TRUE); - AppendDirtyReflowCommand(GetPresShellNoAddref(aPresContext), this); + AppendDirtyReflowCommand(aPresContext->PresShell(), this); } else { nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(aOldFrame); if (rgFrame) { @@ -2665,7 +2650,7 @@ nsTableFrame::RemoveFrame(nsIPresContext* aPresContext, // XXX This could probably be optimized with much effort SetNeedStrategyInit(PR_TRUE); - AppendDirtyReflowCommand(GetPresShellNoAddref(aPresContext), this); + AppendDirtyReflowCommand(aPresContext->PresShell(), this); } else { // Just remove the frame mFrames.DestroyFrame(aPresContext, aOldFrame); @@ -3283,14 +3268,10 @@ nsTableFrame::ReflowChildren(nsIPresContext* aPresContext, // The child doesn't have a next-in-flow so create a continuing // frame. This hooks the child into the flow nsIFrame* continuingFrame; - nsIPresShell* presShell; - nsIStyleSet* styleSet; - aPresContext->GetShell(&presShell); - presShell->GetStyleSet(&styleSet); - NS_RELEASE(presShell); - styleSet->CreateContinuingFrame(aPresContext, kidFrame, this, &continuingFrame); - NS_RELEASE(styleSet); + aPresContext->PresShell()->GetStyleSet()-> + CreateContinuingFrame(aPresContext, kidFrame, this, + &continuingFrame); // Add the continuing frame to the sibling list continuingFrame->SetNextSibling(kidFrame->GetNextSibling()); @@ -7340,8 +7321,7 @@ nsTableFrame::GetProperty(nsIPresContext* aPresContext, nsIAtom* aPropertyName, PRBool aCreateIfNecessary) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h index 22c13c33d52..39182470c9f 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.h +++ b/mozilla/layout/html/table/src/nsTableFrame.h @@ -238,7 +238,6 @@ public: static nsresult AppendDirtyReflowCommand(nsIPresShell* aPresShell, nsIFrame* aFrame); - static nsIPresShell* GetPresShellNoAddref(nsIPresContext* aPresContext); static void RePositionViews(nsIPresContext* aPresContext, nsIFrame* aFrame); diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp index 2de8cdf057d..afe71fe4f6e 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -1030,9 +1030,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext, // get the style set nsCOMPtr styleSet; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetStyleSet(getter_AddRefs(styleSet)); + aPresContext->PresShell()->GetStyleSet(getter_AddRefs(styleSet)); GET_PIXELS_TO_TWIPS(aPresContext, p2t); nscoord availWidth = nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t); diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 76fea72a0e5..4e719e82bb2 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -652,8 +652,7 @@ nsMathMLContainerFrame::PropagateScriptStyleFor(nsIPresContext* aPresContext, } // now, re-resolve the style contexts in our subtree - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr fm; presShell->GetFrameManager(getter_AddRefs(fm)); @@ -714,10 +713,9 @@ nsMathMLContainerFrame::WrapForeignFrames(nsIPresContext* aPresContext) child->QueryInterface(kInlineFrameCID, (void**)&inlineFrame); if (inlineFrame) { // create a new wrapper frame to wrap this child - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* wrapper; - nsresult rv = NS_NewMathMLForeignFrameWrapper(shell, &wrapper); + nsresult rv = NS_NewMathMLForeignFrameWrapper(aPresContext->PresShell(), + &wrapper); if (NS_FAILED(rv)) return rv; nsRefPtr newStyleContext; newStyleContext = aPresContext->ResolvePseudoStyleContextFor(mContent, @@ -924,9 +922,7 @@ nsMathMLContainerFrame::ReLayoutChildren(nsIPresContext* aPresContext, } // Ask our parent frame to reflow us - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - return frame->ReflowDirtyChild(presShell, nsnull); + return frame->ReflowDirtyChild(aPresContext->PresShell(), nsnull); } // There are precise rules governing children of a MathML frame, @@ -1025,9 +1021,7 @@ nsMathMLContainerFrame::AttributeChanged(nsIPresContext* aPresContext, MapAttributesIntoCSS(aPresContext, this); } - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - return ReflowDirtyChild(presShell, nsnull); + return ReflowDirtyChild(aPresContext->PresShell(), nsnull); } // We are an inline frame, so we handle dirty request like nsInlineFrame diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index 95b7ee262a0..f423d883f69 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -505,10 +505,8 @@ GetMathMLAttributeStyleSheet(nsIPresContext* aPresContext, *aSheet = nsnull; // first, look if the attribute stylesheet is already there - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr styleSet; - presShell->GetStyleSet(getter_AddRefs(styleSet)); + aPresContext->PresShell()->GetStyleSet(getter_AddRefs(styleSet)); if (!styleSet) return; nsAutoString title; @@ -694,8 +692,7 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext, return 0; // now, re-resolve the style contexts in our subtree - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr fm; presShell->GetFrameManager(getter_AddRefs(fm)); diff --git a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp index 3b74536d860..0f2311c927f 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLTokenFrame.cpp @@ -324,8 +324,7 @@ nsMathMLTokenFrame::SetTextStyle(nsIPresContext* aPresContext) mContent->SetAttr(kNameSpaceID_None, nsMathMLAtoms::fontstyle, fontstyle, PR_FALSE); // then, re-resolve the style contexts in our subtree - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr fm; presShell->GetFrameManager(getter_AddRefs(fm)); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 2e1c8f8c7ff..1a0740c15d3 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -417,9 +417,7 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent) mContent->SetAttr(kNameSpaceID_None, nsMathMLAtoms::selection_, value, notify); // Now trigger a content-changed reflow... - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - ReflowDirtyChild(presShell, mSelectedFrame); + ReflowDirtyChild(mPresContext->PresShell(), mSelectedFrame); } } else if (NS_MATHML_ACTION_TYPE_RESTYLE == mActionType) { @@ -438,8 +436,7 @@ nsMathMLmactionFrame::MouseClick(nsIDOMEvent* aMouseEvent) // Cancel the reflow command that the change of attribute has // caused, and post a style changed reflow request that is instead // targeted at our selected frame - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->PresShell(); presShell->CancelReflowCommand(this, nsnull); nsFrame::CreateAndPostReflowCommand(presShell, mSelectedFrame, eReflowType_StyleChanged, nsnull, nsnull, nsnull); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp index ceeb423eae7..ae9df29908b 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -110,12 +110,11 @@ nsMathMLmoFrame::IsFrameInSelection(nsIPresContext* aPresContext, return PR_FALSE; SelectionDetails* details = nsnull; - nsCOMPtr shell; - nsresult rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { nsCOMPtr frameSelection; nsCOMPtr selCon; - rv = GetSelectionController(aPresContext, getter_AddRefs(selCon)); + nsresult rv = GetSelectionController(aPresContext, getter_AddRefs(selCon)); if (NS_SUCCEEDED(rv) && selCon) frameSelection = do_QueryInterface(selCon); if (!frameSelection) diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index 1366eed7cf4..870b80fa7b9 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -116,8 +116,7 @@ GetValueAt(nsIPresContext* aPresContext, PRUnichar* result = nsnull; nsValueList* valueList = nsnull; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; presShell->GetFrameManager(getter_AddRefs(frameManager)); @@ -280,8 +279,7 @@ MapAttributesInto(nsIPresContext* aPresContext, // now, re-resolve the style contexts in our subtree to pick up any changes if (hasChanged) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr fm; presShell->GetFrameManager(getter_AddRefs(fm)); diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 491301fed41..9da169dd6fb 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -1244,9 +1244,7 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings, // end observing the document BEFORE we do any new reflows if (cacheOldPres && !HasCachedPres()) { SetCacheOldPres(PR_TRUE); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->EndObservingDocument(); + mPresContext->PresShell()->EndObservingDocument(); } if (aWebProgressListener != nsnull) { @@ -4690,8 +4688,7 @@ static void RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aInde if (!aPresContext || !out) return; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (shell) { nsIFrame* frame; shell->GetRootFrame(&frame); diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index f0690a06f61..cbfc383bafc 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -737,9 +737,8 @@ HTMLStyleSheetImpl::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, static nsresult GetBodyColor(nsIPresContext* aPresContext, nscolor* aColor) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr doc; + nsIPresShell *shell = aPresContext->PresShell(); shell->GetDocument(getter_AddRefs(doc)); nsCOMPtr domdoc = do_QueryInterface(doc); if (!domdoc) diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 11d1061caa3..daab82714f1 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -1919,8 +1919,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, // check if the prefs have been disabled for this shell // - if prefs are disabled then we use the document fonts anyway (yet another override) PRBool prefsEnabled = PR_TRUE; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mPresContext->GetPresShell(); if (shell) shell->ArePrefStyleRulesEnabled(prefsEnabled); if (!prefsEnabled) @@ -4332,10 +4331,8 @@ nsRuleNode::GetStyleData(nsStyleStructID aSID, // this works fine even if |this| is a rule node that has been // destroyed (leftover from a previous rule tree) but is somehow still // used. - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr set; - shell->GetStyleSet(getter_AddRefs(set)); + mPresContext->PresShell()->GetStyleSet(getter_AddRefs(set)); return set->GetDefaultStyleData()->GetStyleData(aSID); } diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index 788f7f1a550..7511921bc66 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -94,10 +94,8 @@ nsStyleContext::~nsStyleContext() nsIPresContext *presContext = mRuleNode->GetPresContext(); - nsCOMPtr shell; - presContext->GetShell(getter_AddRefs(shell)); nsCOMPtr set; - shell->GetStyleSet(getter_AddRefs(set)); + presContext->PresShell()->GetStyleSet(getter_AddRefs(set)); set->NotifyStyleContextDestroyed(presContext, this); if (mParent) { diff --git a/mozilla/layout/style/nsStyleSet.cpp b/mozilla/layout/style/nsStyleSet.cpp index 4f4f287bade..85de976e1a2 100644 --- a/mozilla/layout/style/nsStyleSet.cpp +++ b/mozilla/layout/style/nsStyleSet.cpp @@ -1608,9 +1608,8 @@ NS_IMETHODIMP StyleSetImpl::ConstructRootFrame(nsIPresContext* aPresContext, nsIContent* aDocElement, nsIFrame*& aFrameSubTree) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - return mFrameConstructor->ConstructRootFrame(shell, aPresContext, aDocElement, + return mFrameConstructor->ConstructRootFrame(aPresContext->PresShell(), + aPresContext, aDocElement, aFrameSubTree); } @@ -1693,9 +1692,8 @@ NS_IMETHODIMP StyleSetImpl::CantRenderReplacedElement(nsIPresContext* aPresContext, nsIFrame* aFrame) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - return mFrameConstructor->CantRenderReplacedElement(shell, aPresContext, aFrame); + return mFrameConstructor-> + CantRenderReplacedElement(aPresContext->PresShell(), aPresContext, aFrame); } NS_IMETHODIMP @@ -1704,9 +1702,9 @@ StyleSetImpl::CreateContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIFrame** aContinuingFrame) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - return mFrameConstructor->CreateContinuingFrame(shell, aPresContext, aFrame, aParentFrame, + return mFrameConstructor->CreateContinuingFrame(aPresContext->PresShell(), + aPresContext, aFrame, + aParentFrame, aContinuingFrame); } diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index c3c01d2f12b..b0472f5bb2e 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -332,12 +332,9 @@ nsTableCellFrame::DecorateForSelection(nsIPresContext* aPresContext, PRBool isSelected = (GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT; if (isSelected) { - nsCOMPtr shell; - nsresult result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; nsCOMPtr frameSelection; - result = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + nsresult result = aPresContext->PresShell()-> + GetFrameSelection(getter_AddRefs(frameSelection)); if (NS_SUCCEEDED(result)) { PRBool tableCellSelectionMode; result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); @@ -536,12 +533,9 @@ nsTableCellFrame::SetSelected(nsIPresContext* aPresContext, // only this frame is considered nsFrame::SetSelected(aPresContext, aRange, aSelected, aSpread); - nsCOMPtr shell; - nsresult result = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_FAILED(result)) - return result; nsCOMPtr frameSelection; - result = shell->GetFrameSelection(getter_AddRefs(frameSelection)); + nsresult result = aPresContext->PresShell()-> + GetFrameSelection(getter_AddRefs(frameSelection)); if (NS_SUCCEEDED(result) && frameSelection) { PRBool tableCellSelectionMode; result = frameSelection->GetTableCellSelection(&tableCellSelectionMode); diff --git a/mozilla/layout/tables/nsTableColGroupFrame.cpp b/mozilla/layout/tables/nsTableColGroupFrame.cpp index 8be89bcbf5e..48b366bf175 100644 --- a/mozilla/layout/tables/nsTableColGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableColGroupFrame.cpp @@ -318,7 +318,7 @@ nsTableColGroupFrame::RemoveChild(nsIPresContext& aPresContext, // XXX this could be optimized with much effort tableFrame->SetNeedStrategyInit(PR_TRUE); // Generate a reflow command so we reflow the table - nsTableFrame::AppendDirtyReflowCommand(nsTableFrame::GetPresShellNoAddref(&aPresContext), tableFrame); + nsTableFrame::AppendDirtyReflowCommand(aPresContext.PresShell(), tableFrame); } // this removes children form the last col group (eColGroupAnonymousCell) in the diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index d682f7eed37..b2d20186eb2 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -382,18 +382,6 @@ nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame, return PR_FALSE; } -nsIPresShell* -nsTableFrame::GetPresShellNoAddref(nsIPresContext* aPresContext) -{ - nsIPresShell* tempShell; - nsIPresShell* presShell; - aPresContext->GetShell(&tempShell); - presShell = tempShell; - NS_RELEASE(tempShell); // presShell is needed because this sets tempShell to nsnull - - return presShell; -} - // XXX this needs to be cleaned up so that the frame constructor breaks out col group // frames into a separate child list. NS_IMETHODIMP @@ -490,7 +478,7 @@ void nsTableFrame::AttributeChangedFor(nsIPresContext* aPresContext, // XXX This could probably be optimized with some effort SetNeedStrategyInit(PR_TRUE); - AppendDirtyReflowCommand(GetPresShellNoAddref(aPresContext), this); + AppendDirtyReflowCommand(aPresContext->PresShell(), this); } } } @@ -837,9 +825,8 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext, mStyleContext); // Create a col group frame nsIFrame* newFrame; - nsCOMPtr presShell; - aPresContext.GetShell(getter_AddRefs(presShell)); - nsresult result = NS_NewTableColGroupFrame(presShell, &newFrame); + nsresult result = NS_NewTableColGroupFrame(aPresContext.PresShell(), + &newFrame); if (NS_SUCCEEDED(result) && newFrame) { ((nsTableColGroupFrame *)newFrame)->SetColType(aColGroupType); newFrame->Init(&aPresContext, colGroupContent, this, colGroupStyle, nsnull); @@ -953,9 +940,7 @@ nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext, // create the new col frame nsIFrame* colFrame; - nsCOMPtr presShell; - aPresContext.GetShell(getter_AddRefs(presShell)); - NS_NewTableColFrame(presShell, &colFrame); + NS_NewTableColFrame(aPresContext.PresShell(), &colFrame); ((nsTableColFrame *) colFrame)->SetColType(aColType); colFrame->Init(&aPresContext, iContent, &aColGroupFrame, styleContext, nsnull); @@ -2636,7 +2621,7 @@ nsTableFrame::RemoveFrame(nsIPresContext* aPresContext, // XXX This could probably be optimized with much effort SetNeedStrategyInit(PR_TRUE); - AppendDirtyReflowCommand(GetPresShellNoAddref(aPresContext), this); + AppendDirtyReflowCommand(aPresContext->PresShell(), this); } else { nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(aOldFrame); if (rgFrame) { @@ -2665,7 +2650,7 @@ nsTableFrame::RemoveFrame(nsIPresContext* aPresContext, // XXX This could probably be optimized with much effort SetNeedStrategyInit(PR_TRUE); - AppendDirtyReflowCommand(GetPresShellNoAddref(aPresContext), this); + AppendDirtyReflowCommand(aPresContext->PresShell(), this); } else { // Just remove the frame mFrames.DestroyFrame(aPresContext, aOldFrame); @@ -3283,14 +3268,10 @@ nsTableFrame::ReflowChildren(nsIPresContext* aPresContext, // The child doesn't have a next-in-flow so create a continuing // frame. This hooks the child into the flow nsIFrame* continuingFrame; - nsIPresShell* presShell; - nsIStyleSet* styleSet; - aPresContext->GetShell(&presShell); - presShell->GetStyleSet(&styleSet); - NS_RELEASE(presShell); - styleSet->CreateContinuingFrame(aPresContext, kidFrame, this, &continuingFrame); - NS_RELEASE(styleSet); + aPresContext->PresShell()->GetStyleSet()-> + CreateContinuingFrame(aPresContext, kidFrame, this, + &continuingFrame); // Add the continuing frame to the sibling list continuingFrame->SetNextSibling(kidFrame->GetNextSibling()); @@ -7340,8 +7321,7 @@ nsTableFrame::GetProperty(nsIPresContext* aPresContext, nsIAtom* aPropertyName, PRBool aCreateIfNecessary) { - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->GetPresShell(); if (presShell) { nsCOMPtr frameManager; diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index 22c13c33d52..39182470c9f 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -238,7 +238,6 @@ public: static nsresult AppendDirtyReflowCommand(nsIPresShell* aPresShell, nsIFrame* aFrame); - static nsIPresShell* GetPresShellNoAddref(nsIPresContext* aPresContext); static void RePositionViews(nsIPresContext* aPresContext, nsIFrame* aFrame); diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 2de8cdf057d..afe71fe4f6e 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -1030,9 +1030,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext, // get the style set nsCOMPtr styleSet; - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetStyleSet(getter_AddRefs(styleSet)); + aPresContext->PresShell()->GetStyleSet(getter_AddRefs(styleSet)); GET_PIXELS_TO_TWIPS(aPresContext, p2t); nscoord availWidth = nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t); diff --git a/mozilla/layout/xul/base/src/nsBox.cpp b/mozilla/layout/xul/base/src/nsBox.cpp index d6df7a711fa..266fd1f8fc8 100644 --- a/mozilla/layout/xul/base/src/nsBox.cpp +++ b/mozilla/layout/xul/base/src/nsBox.cpp @@ -1096,10 +1096,8 @@ nsBox::Redraw(nsBoxLayoutState& aState, return NS_OK; } - nsCOMPtr shell; - presContext->GetShell(getter_AddRefs(shell)); PRBool suppressed = PR_FALSE; - shell->IsPaintingSuppressed(&suppressed); + presContext->PresShell()->IsPaintingSuppressed(&suppressed); if (suppressed) return NS_OK; // Don't redraw. Painting is still suppressed. diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 92763b4e3f4..48fd2843f0f 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -217,13 +217,10 @@ nsBoxFrame::SetInitialChildList(nsIPresContext* aPresContext, { SanityCheck(mFrames); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsresult r = nsContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); if (r == NS_OK) { // initialize our list of infos. - nsBoxLayoutState state(shell); + nsBoxLayoutState state(aPresContext->PresShell()); InitChildren(state, aChildList); CheckFrameOrder(); } else { @@ -751,9 +748,8 @@ nsBoxFrame::IsInitialReflowForPrintPreview(nsBoxLayoutState& aState, // See if we are doing Print Preview nsCOMPtr ppContent(do_QueryInterface(aState.GetPresContext())); if (ppContent) { - // Now, get the current URI to see of we doing chrome - nsCOMPtr presShell; - aState.GetPresContext()->GetShell(getter_AddRefs(presShell)); + // Now, get the current URI to see if we doing chrome + nsIPresShell *presShell = aState.GetPresContext()->GetPresShell(); if (!presShell) return PR_FALSE; nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); @@ -1296,9 +1292,7 @@ nsBoxFrame::AttributeChanged(nsIPresContext* aPresContext, } } else if (aAttribute == nsXULAtoms::ordinal) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - nsBoxLayoutState state(shell); + nsBoxLayoutState state(aPresContext->PresShell()); nsIBox* parent; GetParentBox(&parent); @@ -1316,8 +1310,6 @@ nsBoxFrame::AttributeChanged(nsIPresContext* aPresContext, RegUnregAccessKey(aPresContext, PR_TRUE); } - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsBoxLayoutState state(aPresContext); // XXX This causes us to reflow for any attribute change (e.g., // flipping through menus). @@ -1442,9 +1434,7 @@ nsBoxFrame::Paint(nsIPresContext* aPresContext, // and frame construction. If painting is locked down, then we // do not paint our children. PRBool paintingSuppressed = PR_FALSE; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->IsPaintingSuppressed(&paintingSuppressed); + aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed); if (paintingSuppressed) return NS_OK; } diff --git a/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp b/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp index 2db41822463..6d7069ba051 100644 --- a/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp +++ b/mozilla/layout/xul/base/src/nsBoxLayoutState.cpp @@ -59,6 +59,7 @@ nsBoxLayoutState::nsBoxLayoutState(nsIPresContext* aPresContext):mPresContext(aP mLayoutFlags(0), mDisablePainting(PR_FALSE) { + NS_ASSERTION(mPresContext, "PresContext must be non-null"); } nsBoxLayoutState::nsBoxLayoutState(const nsBoxLayoutState& aState) @@ -70,6 +71,8 @@ nsBoxLayoutState::nsBoxLayoutState(const nsBoxLayoutState& aState) mScrolledBlockSizeConstraint = aState.mScrolledBlockSizeConstraint; mLayoutFlags = aState.mLayoutFlags; mDisablePainting = aState.mDisablePainting; + + NS_ASSERTION(mPresContext, "PresContext must be non-null"); } nsBoxLayoutState::nsBoxLayoutState(nsIPresShell* aShell):mReflowState(nsnull), @@ -81,6 +84,7 @@ nsBoxLayoutState::nsBoxLayoutState(nsIPresShell* aShell):mReflowState(nsnull), mDisablePainting(PR_FALSE) { aShell->GetPresContext(getter_AddRefs(mPresContext)); + NS_ASSERTION(mPresContext, "PresContext must be non-null"); } nsBoxLayoutState::nsBoxLayoutState(nsIPresContext* aPresContext, @@ -97,6 +101,7 @@ nsBoxLayoutState::nsBoxLayoutState(nsIPresContext* aPresContext, { mMaxElementWidth = &aDesiredSize.mMaxElementWidth; + NS_ASSERTION(mPresContext, "PresContext must be non-null"); } nscoord* @@ -372,37 +377,25 @@ nsBoxLayoutState::RecycleFreedMemory(nsIPresShell* aShell, void* aMem) nsresult nsBoxLayoutState::GetPresShell(nsIPresShell** aShell) { - if (mPresContext) - return mPresContext->GetShell(aShell); - else { - *aShell = nsnull; - return NS_OK; - } + NS_IF_ADDREF(*aShell = mPresContext->GetPresShell()); + return NS_OK; } nsresult nsBoxLayoutState::PushStackMemory() { - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - return shell->PushStackMemory(); + return mPresContext->PresShell()->PushStackMemory(); } nsresult nsBoxLayoutState::PopStackMemory() { - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - - return shell->PopStackMemory(); + return mPresContext->PresShell()->PopStackMemory(); } nsresult nsBoxLayoutState::AllocateStackMemory(size_t aSize, void** aResult) { - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - - return shell->AllocateStackMemory(aSize, aResult); + return mPresContext->PresShell()->AllocateStackMemory(aSize, aResult); } diff --git a/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp b/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp index f993e004870..08b4a484548 100644 --- a/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsButtonBoxFrame.cpp @@ -160,8 +160,6 @@ nsButtonBoxFrame::MouseClicked (nsIPresContext* aPresContext, nsGUIEvent* aEvent if (disabled.Equals(NS_LITERAL_STRING("true"))) return; - nsresult rv = NS_OK; - // Execute the oncommand event handler. nsEventStatus status = nsEventStatus_eIgnore; nsMouseEvent event; @@ -182,9 +180,9 @@ nsButtonBoxFrame::MouseClicked (nsIPresContext* aPresContext, nsGUIEvent* aEvent event.widget = nsnull; // Have the content handle the event, propagating it according to normal DOM rules. - nsCOMPtr shell; - rv = aPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsIPresShell *shell = aPresContext->GetPresShell(); + if (shell) { shell->HandleDOMEventWithTarget(mContent, &event, &status); + // shell may no longer be alive, don't use it here unless you keep a ref } } diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index 12addab066e..b10a1b3e400 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -698,8 +698,7 @@ nsImageBoxFrame::GetFrameName(nsAString& aResult) const void nsImageBoxFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->GetPresShell(); if (!shell) return; diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index 55c6a3c26dd..065ed23685d 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -272,11 +272,8 @@ NS_IMETHODIMP nsListBoxBodyFrame::Destroy(nsIPresContext* aPresContext) { // make sure we cancel any posted callbacks. - if (mReflowCallbackPosted) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->CancelReflowCallback(this); - } + if (mReflowCallbackPosted) + aPresContext->PresShell()->CancelReflowCallback(this); return nsBoxFrame::Destroy(aPresContext); } @@ -380,9 +377,7 @@ nsListBoxBodyFrame::PositionChanged(PRInt32 aOldIndex, PRInt32& aNewIndex) smoother->Stop(); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->FlushPendingNotifications(PR_FALSE); + mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); smoother->mDelta = newTwipIndex > oldTwipIndex ? rowDelta : -rowDelta; @@ -791,9 +786,7 @@ nsListBoxBodyFrame::PostReflowCallback() { if (!mReflowCallbackPosted) { mReflowCallbackPosted = PR_TRUE; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->PostReflowCallback(this); + mPresContext->PresShell()->PostReflowCallback(this); } } @@ -852,8 +845,7 @@ nsListBoxBodyFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta, PRBool a // begin timing how long it takes to scroll a row PRTime start = PR_Now(); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mPresContext->PresShell(); shell->FlushPendingNotifications(PR_FALSE); PRInt32 visibleRows = 0; @@ -1260,8 +1252,7 @@ nsListBoxBodyFrame::OnContentInserted(nsIPresContext* aPresContext, nsIContent* { ++mRowCount; - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); // The RDF content builder will build content nodes such that they are all // ready when OnContentInserted is first called, meaning the first call // to CreateRows will create all the frames, but OnContentInserted will @@ -1333,10 +1324,9 @@ nsListBoxBodyFrame::OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aCh PRUint32 childCount = listBoxContent->GetChildCount(); if (childCount > 0) { nsIContent *lastChild = listBoxContent->GetChildAt(childCount - 1); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* lastChildFrame = nsnull; - shell->GetPrimaryFrameFor(lastChild, &lastChildFrame); + aPresContext->PresShell()->GetPrimaryFrameFor(lastChild, + &lastChildFrame); if (lastChildFrame) { mTopFrame = nsnull; @@ -1362,9 +1352,7 @@ nsListBoxBodyFrame::OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aCh } MarkDirtyChildren(state); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->FlushPendingNotifications(PR_FALSE); + aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } void diff --git a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp index 47d1753ece1..4c154e3ab05 100644 --- a/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuBarFrame.cpp @@ -203,8 +203,7 @@ nsMenuBarFrame::SetActive(PRBool aActiveFlag) // The caret distracts screen readers and other assistive technologies from the menu selection // There is 1 caret per document, we need to find the focused document and toggle its caret do { - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = mPresContext->GetPresShell(); if (!presShell) break; @@ -313,9 +312,7 @@ nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent) // Enumerate over our list of frames. nsIFrame* immediateParent = nsnull; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - GetInsertionPoint(shell, this, nsnull, &immediateParent); + GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent); if (!immediateParent) immediateParent = this; @@ -442,9 +439,7 @@ NS_IMETHODIMP nsMenuBarFrame::GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) { nsIFrame* immediateParent = nsnull; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - GetInsertionPoint(shell, this, nsnull, &immediateParent); + GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent); if (!immediateParent) immediateParent = this; @@ -499,9 +494,7 @@ NS_IMETHODIMP nsMenuBarFrame::GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) { nsIFrame* immediateParent = nsnull; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - GetInsertionPoint(shell, this, nsnull, &immediateParent); + GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent); if (!immediateParent) immediateParent = this; diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index f3980926b97..e8f823ef519 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -812,9 +812,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag) { menuPopup->MarkDirty(state); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->FlushPendingNotifications(PR_FALSE); + mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } nsRect curRect; @@ -835,9 +833,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag) if (curRect.height != rect.height || mLastPref.height != rect.height) { menuPopup->MarkDirty(state); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->FlushPendingNotifications(PR_FALSE); + mPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); } ActivateMenu(PR_TRUE); @@ -1661,11 +1657,12 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent) // associated view manager on exit from this function. // See bug 54233. nsCOMPtr kungFuDeathGrip = mPresContext->GetViewManager(); - nsCOMPtr shell; - nsresult result = mPresContext->GetShell(getter_AddRefs(shell)); + // keep a reference so we can safely use this after dispatching the DOM event + nsCOMPtr shell = mPresContext->GetPresShell(); nsIFrame* me = this; - if (NS_SUCCEEDED(result) && shell) { + if (shell) { shell->HandleDOMEventWithTarget(mContent, &event, &status); + // shell may no longer be alive, don't use it here unless you keep a ref } // XXX HACK. Just gracefully exit if the node has been removed, e.g., window.close() @@ -1702,16 +1699,17 @@ nsMenuFrame::OnCreate() nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); - nsresult rv; - nsCOMPtr shell; - rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { if (child) { rv = shell->HandleDOMEventWithTarget(child, &event, &status); } else { rv = shell->HandleDOMEventWithTarget(mContent, &event, &status); } + // shell may no longer be alive, don't use it here unless you keep a ref } if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) @@ -1798,16 +1796,16 @@ nsMenuFrame::OnCreated() nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); - nsresult rv; - nsCOMPtr shell; - rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { if (child) { rv = shell->HandleDOMEventWithTarget(child, &event, &status); } else { rv = shell->HandleDOMEventWithTarget(mContent, &event, &status); } + // shell may no longer be alive, don't use it here unless you keep a ref } if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) @@ -1832,16 +1830,16 @@ nsMenuFrame::OnDestroy() nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); - nsresult rv; - nsCOMPtr shell; - rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { if (child) { rv = shell->HandleDOMEventWithTarget(child, &event, &status); } else { rv = shell->HandleDOMEventWithTarget(mContent, &event, &status); } + // shell may no longer be alive, don't use it here unless you keep a ref } if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) @@ -1866,16 +1864,16 @@ nsMenuFrame::OnDestroyed() nsCOMPtr child; GetMenuChildrenElement(getter_AddRefs(child)); - nsresult rv; - nsCOMPtr shell; - rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { + nsresult rv = NS_OK; + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { if (child) { rv = shell->HandleDOMEventWithTarget(child, &event, &status); } else { rv = shell->HandleDOMEventWithTarget(mContent, &event, &status); } + // shell may no longer be alive, don't use it here unless you keep a ref } if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) @@ -2063,10 +2061,8 @@ nsMenuFrame::SetActiveChild(nsIDOMElement* aChild) nsCOMPtr child(do_QueryInterface(aChild)); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* kid; - shell->GetPrimaryFrameFor(child, &kid); + mPresContext->PresShell()->GetPrimaryFrameFor(child, &kid); if (!kid) return NS_ERROR_FAILURE; nsCOMPtr menuFrame(do_QueryInterface(kid)); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 54c3b4fa0a5..f9b324aa65f 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -85,10 +85,8 @@ const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere f static nsIPopupSetFrame* GetPopupSetFrame(nsIPresContext* aPresContext) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* rootFrame; - shell->GetRootFrame(&rootFrame); + aPresContext->PresShell()->GetRootFrame(&rootFrame); if (!rootFrame) return nsnull; @@ -922,8 +920,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext, dx->GetAppUnitsToDevUnits(t2p); // get the document and the global script object - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); + nsIPresShell *presShell = aPresContext->PresShell(); nsCOMPtr document; presShell->GetDocument(getter_AddRefs(document)); @@ -1245,9 +1242,7 @@ NS_IMETHODIMP nsMenuPopupFrame::GetNextMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) { nsIFrame* immediateParent = nsnull; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - GetInsertionPoint(shell, this, nsnull, &immediateParent); + GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent); if (!immediateParent) immediateParent = this; @@ -1303,9 +1298,7 @@ NS_IMETHODIMP nsMenuPopupFrame::GetPreviousMenuItem(nsIMenuFrame* aStart, nsIMenuFrame** aResult) { nsIFrame* immediateParent = nsnull; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - GetInsertionPoint(shell, this, nsnull, &immediateParent); + GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent); if (!immediateParent) immediateParent = this; @@ -1613,9 +1606,7 @@ nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, PRBool& doActi // Enumerate over our list of frames. nsIFrame* immediateParent = nsnull; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - GetInsertionPoint(shell, this, nsnull, &immediateParent); + GetInsertionPoint(mPresContext->PresShell(), this, nsnull, &immediateParent); if (!immediateParent) immediateParent = this; diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp index d58121d626d..e61b81191d4 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp @@ -326,10 +326,9 @@ nsPopupSetFrame::RepositionPopup(nsPopupFrameList* aEntry, nsBoxLayoutState& aSt // Sync up the view. if (aEntry && aEntry->mElementContent) { nsIFrame* frameToSyncTo = nsnull; - nsCOMPtr presShell; nsIPresContext* presContext = aState.GetPresContext(); - presContext->GetShell(getter_AddRefs(presShell)); - presShell->GetPrimaryFrameFor(aEntry->mElementContent, &frameToSyncTo ); + presContext->PresShell()->GetPrimaryFrameFor(aEntry->mElementContent, + &frameToSyncTo ); ((nsMenuPopupFrame*)(aEntry->mPopupFrame))->SyncViewWithFrame(presContext, aEntry->mPopupAnchor, aEntry->mPopupAlign, frameToSyncTo, aEntry->mXPos, aEntry->mYPos); } @@ -365,9 +364,8 @@ nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupConten entry->mYPos = aYPos; // If a frame exists already, go ahead and use it. - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->GetPrimaryFrameFor(aPopupContent, &entry->mPopupFrame); + mPresContext->PresShell()->GetPrimaryFrameFor(aPopupContent, + &entry->mPopupFrame); #ifdef DEBUG_PINK printf("X Pos: %d\n", mXPos); @@ -414,9 +412,8 @@ nsPopupSetFrame::HidePopup(nsIFrame* aPopup) // popup. if (entry->mElementContent->Tag() == nsXULAtoms::menupopup) { nsIFrame* popupFrame = nsnull; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetPrimaryFrameFor(entry->mElementContent, &popupFrame); + mPresContext->PresShell()->GetPrimaryFrameFor(entry->mElementContent, + &popupFrame); if (popupFrame) { nsCOMPtr menuParent(do_QueryInterface(popupFrame)); if (menuParent) @@ -446,9 +443,8 @@ nsPopupSetFrame::DestroyPopup(nsIFrame* aPopup, PRBool aDestroyEntireChain) // menu popup. if (entry->mElementContent->Tag() == nsXULAtoms::menupopup) { nsIFrame* popupFrame = nsnull; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); - presShell->GetPrimaryFrameFor(entry->mElementContent, &popupFrame); + mPresContext->PresShell()->GetPrimaryFrameFor(entry->mElementContent, + &popupFrame); if (popupFrame) { nsCOMPtr menuParent(do_QueryInterface(popupFrame)); if (menuParent) @@ -592,15 +588,15 @@ nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent) event.point.y = aY; if (aPopupContent) { - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { - rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, &status); + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { + nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, + &status); + // shell may no longer be alive, don't use it here unless you keep a ref + if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) + return PR_FALSE; } - if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) - return PR_FALSE; - // The menu is going to show, and the create handler has executed. // We should now walk all of our menu item children, checking to see if any // of them has a command attribute. If so, then several attributes must @@ -677,14 +673,14 @@ nsPopupSetFrame::OnCreated(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent) event.point.y = aY; if (aPopupContent) { - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { - rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, &status); + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { + nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, + &status); + // shell may no longer be alive, don't use it here unless you keep a ref + if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) + return PR_FALSE; } - - if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) - return PR_FALSE; } return PR_TRUE; @@ -705,13 +701,14 @@ nsPopupSetFrame::OnDestroy(nsIContent* aPopupContent) event.widget = nsnull; if (aPopupContent) { - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { - rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, &status); + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { + nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, + &status); + // shell may no longer be alive, don't use it here unless you keep a ref + if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) + return PR_FALSE; } - if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) - return PR_FALSE; } return PR_TRUE; } @@ -731,13 +728,14 @@ nsPopupSetFrame::OnDestroyed(nsIContent* aPopupContent) event.widget = nsnull; if (aPopupContent) { - nsCOMPtr shell; - nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); - if (NS_SUCCEEDED(rv) && shell) { - rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, &status); + nsIPresShell *shell = mPresContext->GetPresShell(); + if (shell) { + nsresult rv = shell->HandleDOMEventWithTarget(aPopupContent, &event, + &status); + // shell may no longer be alive, don't use it here unless you keep a ref + if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) + return PR_FALSE; } - if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault ) - return PR_FALSE; } return PR_TRUE; } diff --git a/mozilla/layout/xul/base/src/nsResizerFrame.cpp b/mozilla/layout/xul/base/src/nsResizerFrame.cpp index a2a22e20a7a..77db136bdb3 100644 --- a/mozilla/layout/xul/base/src/nsResizerFrame.cpp +++ b/mozilla/layout/xul/base/src/nsResizerFrame.cpp @@ -152,10 +152,8 @@ nsResizerFrame::HandleEvent(nsIPresContext* aPresContext, if(mTrackingMouseMove) { // get the document and the global script object - should this be cached? - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr document; - presShell->GetDocument(getter_AddRefs(document)); + aPresContext->PresShell()->GetDocument(getter_AddRefs(document)); nsIScriptGlobalObject *scriptGlobalObject = document->GetScriptGlobalObject(); NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE); diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.cpp b/mozilla/layout/xul/base/src/nsSliderFrame.cpp index 58fd4cc0866..cde83fbed6e 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSliderFrame.cpp @@ -278,8 +278,6 @@ nsSliderFrame::AttributeChanged(nsIPresContext* aPresContext, if (aAttribute == nsXULAtoms::maxpos || aAttribute == nsXULAtoms::pageincrement || aAttribute == nsXULAtoms::increment) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsBoxLayoutState state(aPresContext); MarkDirtyChildren(state); diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index 6531c895e4b..38a00cabd0e 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -631,8 +631,7 @@ nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent */ /* - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = aPresContext->PresShell(); nsCOMPtr reflowCmd; nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), mOuter->mParent, @@ -640,9 +639,6 @@ nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent if (NS_SUCCEEDED(rv)) shell->AppendReflowCommand(reflowCmd); - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - mOuter->mState |= NS_FRAME_IS_DIRTY; mOuter->mParent->ReflowDirtyChild(shell, mOuter); */ @@ -1041,8 +1037,6 @@ nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext) if (realTimeDrag) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* frame = nsnull; mParentBox->GetFrame(&frame); @@ -1056,7 +1050,7 @@ nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext) nsIViewManager* viewManager = view->GetViewManager(); viewManager->DisableRefresh(); - shell->FlushPendingNotifications(PR_FALSE); + aPresContext->PresShell()->FlushPendingNotifications(PR_FALSE); viewManager->EnableRefresh(NS_VMREFRESH_IMMEDIATE); } else { @@ -1072,9 +1066,6 @@ nsSplitterFrameInner::AdjustChildren(nsIPresContext* aPresContext, nsSplitterInf nsBoxLayoutState state(aPresContext); - nsCOMPtr shell; - state.GetPresShell(getter_AddRefs(shell)); - float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); nscoord onePixel = NSIntPixelsToTwips(1, p2t); diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp index 35f55afccda..06eb36405f8 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp @@ -167,10 +167,8 @@ nsTitleBarFrame::HandleEvent(nsIPresContext* aPresContext, if(mTrackingMouseMove) { // get the document and the global script object - should this be cached? - nsCOMPtr presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr document; - presShell->GetDocument(getter_AddRefs(document)); + aPresContext->PresShell()->GetDocument(getter_AddRefs(document)); nsCOMPtr window(do_QueryInterface(document->GetScriptGlobalObject())); diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 7d475a13ae9..6cdf441ace7 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -477,10 +477,8 @@ nsTreeBodyFrame::CalcMaxRowWidth(nsBoxLayoutState& aState) nsTreeColumn* col; EnsureColumns(); - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr rc; - presShell->CreateRenderingContext(this, getter_AddRefs(rc)); + mPresContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc)); for (PRInt32 row = 0; row < mRowCount; ++row) { rowWidth = 0; @@ -506,9 +504,7 @@ nsTreeBodyFrame::Destroy(nsIPresContext* aPresContext) { // Make sure we cancel any posted callbacks. if (mReflowCallbackPosted) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); - shell->CancelReflowCallback(this); + aPresContext->PresShell()->CancelReflowCallback(this); mReflowCallbackPosted = PR_FALSE; } @@ -636,9 +632,7 @@ nsTreeBodyFrame::SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRec { if (aRect != mRect && !mReflowCallbackPosted) { mReflowCallbackPosted = PR_TRUE; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); - shell->PostReflowCallback(this); + mPresContext->PresShell()->PostReflowCallback(this); } return nsLeafBoxFrame::SetBounds(aBoxLayoutState, aRect); @@ -1008,10 +1002,8 @@ nsTreeBodyFrame::EnsureScrollbar() // Try to find it. nsCOMPtr parContent; GetBaseElement(getter_AddRefs(parContent)); - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* treeFrame; - shell->GetPrimaryFrameFor(parContent, &treeFrame); + mPresContext->PresShell()->GetPrimaryFrameFor(parContent, &treeFrame); if (treeFrame) mScrollbar = InitScrollbarFrame(mPresContext, treeFrame, this); } @@ -1398,10 +1390,9 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, con textRect.height = height + bp.top + bp.bottom; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr rc; - shell->CreateRenderingContext(this, getter_AddRefs(rc)); + mPresContext->PresShell()->CreateRenderingContext(this, + getter_AddRefs(rc)); rc->SetFont(fm); nscoord width; rc->GetWidth(cellText, width); @@ -1623,10 +1614,8 @@ NS_IMETHODIMP nsTreeBodyFrame::IsCellCropped(PRInt32 aRow, const nsAString& aColID, PRBool *_retval) { nscoord currentSize, desiredSize; - nsCOMPtr presShell; - mPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr rc; - presShell->CreateRenderingContext(this, getter_AddRefs(rc)); + mPresContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc)); GetCellWidth(aRow, aColID, rc, desiredSize, currentSize); *_retval = desiredSize > currentSize; @@ -3423,8 +3412,7 @@ nsTreeBodyFrame::EnsureColumns() if (!parent) return; - nsCOMPtr shell; - mPresContext->GetShell(getter_AddRefs(shell)); + nsIPresShell *shell = mPresContext->PresShell(); // Note: this is dependent on the anonymous content for select // defined in select.xml diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp index 7bbf130b7bd..ad2656844ba 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp @@ -221,10 +221,8 @@ nsTreeColFrame::InvalidateColumnCache(nsIPresContext* aPresContext) mTree->GetTreeBody(getter_AddRefs(bodyEl)); nsCOMPtr bodyContent = do_QueryInterface(bodyEl); if (bodyContent) { - nsCOMPtr shell; - aPresContext->GetShell(getter_AddRefs(shell)); nsIFrame* frame; - shell->GetPrimaryFrameFor(bodyContent, &frame); + aPresContext->PresShell()->GetPrimaryFrameFor(bodyContent, &frame); if (frame) { nsTreeBodyFrame* oframe = NS_STATIC_CAST(nsTreeBodyFrame*, frame); oframe->InvalidateColumnCache(); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index fcd9e5e63fc..348ad4fb040 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -466,7 +466,7 @@ GetPresShellFor(nsIDocShell* aDocShell) nsCOMPtr cx; docv->GetPresContext(getter_AddRefs(cx)); if (nsnull != cx) { - cx->GetShell(&shell); + NS_IF_ADDREF(shell = cx->GetPresShell()); } NS_RELEASE(docv); } diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index 006c9be9017..206897bbd6a 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -911,7 +911,7 @@ nsWebCrawler::GetPresShell(nsIWebShell* aWebShell) nsCOMPtr cx; docv->GetPresContext(getter_AddRefs(cx)); if (nsnull != cx) { - cx->GetShell(&shell); + NS_IF_ADDREF(shell = cx->GetPresShell()); } NS_RELEASE(docv); } diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp index cf49817249b..dc5ad8927ee 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp @@ -572,7 +572,6 @@ NS_IMETHODIMP nsXPBaseWindow::GetPresShell(nsIPresShell*& aPresShell) { aPresShell = nsnull; - nsIPresShell* shell = nsnull; nsCOMPtr docShell(do_QueryInterface(mWebShell)); if (docShell) { nsIContentViewer* cv = nsnull; @@ -584,8 +583,7 @@ NS_IMETHODIMP nsXPBaseWindow::GetPresShell(nsIPresShell*& aPresShell) nsCOMPtr cx; docv->GetPresContext(getter_AddRefs(cx)); if (nsnull != cx) { - cx->GetShell(&shell); // does an add ref - aPresShell = shell; + NS_IF_ADDREF(aPresShell = cx->GetPresShell()); } NS_RELEASE(docv); } diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index e0b284ee31c..a63b25a4248 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -979,12 +979,6 @@ void nsWebShellWindow::DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aP return; } - nsCOMPtr presShell; - if (NS_FAILED(rv = presContext->GetShell(getter_AddRefs(presShell)))) { - NS_ERROR("Unable to retrieve the shell from the presentation context."); - return; - } - nsRect rect; if (NS_FAILED(rv = mWindow->GetClientBounds(rect))) {