Remove non-inlined version of nsIPresShell::GetDocument(). Bug 253889, r+sr=roc.

This commit is contained in:
bryner%brianryner.com 2004-08-02 04:52:55 +00:00
Родитель d6a489ba26
Коммит 18fa617572
60 изменённых файлов: 200 добавлений и 485 удалений

Просмотреть файл

@ -112,9 +112,7 @@ NS_IMETHODIMP nsAccessNode::Init()
// Create a doc accessible so we can cache this node
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
if (presShell) {
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMNode> docNode(do_QueryInterface(doc));
nsCOMPtr<nsIDOMNode> docNode(do_QueryInterface(presShell->GetDocument()));
if (docNode) {
nsCOMPtr<nsIAccessibilityService> accService =
do_GetService("@mozilla.org/accessibilityService;1");

Просмотреть файл

@ -683,9 +683,7 @@ void nsAccessible::GetScrollOffset(nsRect *aRect)
{
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
if (shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentView> docView(do_QueryInterface(doc));
nsCOMPtr<nsIDOMDocumentView> docView(do_QueryInterface(shell->GetDocument()));
if (!docView)
return;

Просмотреть файл

@ -59,11 +59,8 @@ nsAccessibleTreeWalker::nsAccessibleTreeWalker(nsIWeakReference* aPresShell, nsI
if (aWalkAnonContent) {
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
if (presShell) {
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
mBindingManager = doc->GetBindingManager();
}
if (presShell)
mBindingManager = presShell->GetDocument()->GetBindingManager();
}
MOZ_COUNT_CTOR(nsAccessibleTreeWalker);
}

Просмотреть файл

@ -95,8 +95,7 @@ NS_IMETHODIMP nsCaretAccessible::AttachNewSelectionListener(nsIDOMNode *aCurrent
if (!presShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocument> doc = presShell->GetDocument();
if (!doc) // we also should try to QI to document instead (necessary to do when node is a document)
doc = do_QueryInterface(aCurrentNode);
nsCOMPtr<nsIContent> content(do_QueryInterface(aCurrentNode));

Просмотреть файл

@ -90,7 +90,7 @@ nsDocAccessible::nsDocAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell)
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
if (shell) {
shell->GetDocument(getter_AddRefs(mDocument));
mDocument = shell->GetDocument();
nsIViewManager* vm = shell->GetViewManager();
if (vm) {
nsCOMPtr<nsIWidget> widget;

Просмотреть файл

@ -53,12 +53,11 @@ nsHTMLImageAccessible::nsHTMLImageAccessible(nsIDOMNode* aDOMNode, nsIWeakRefere
nsLinkableAccessible(aDOMNode, aShell)
{
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aDOMNode));
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
if (!shell)
return;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
nsAutoString mapElementName;
if (doc && element) {

Просмотреть файл

@ -1744,8 +1744,7 @@ nsPrintEngine::IsParentAFrameSet(nsIWebShell * aParent)
// only check to see if there is a frameset if there is
// NO parent doc for this doc. meaning this parent is the root doc
if (shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {

Просмотреть файл

@ -1,114 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPrintObject.h"
#include "imgIContainer.h"
//---------------------------------------------------
//-- nsPrintObject Class Impl
//---------------------------------------------------
nsPrintObject::nsPrintObject() :
mFrameType(eFrame), mStyleSet(nsnull),
mRootView(nsnull), mContent(nsnull),
mSeqFrame(nsnull), mPageFrame(nsnull), mPageNum(-1),
mRect(0,0,0,0), mReflowRect(0,0,0,0),
mParent(nsnull), mHasBeenPrinted(PR_FALSE), mDontPrint(PR_TRUE),
mPrintAsIs(PR_FALSE), mSkippedPageEject(PR_FALSE), mSharedPresShell(PR_FALSE), mIsHidden(PR_FALSE),
mClipRect(-1,-1, -1, -1),
mImgAnimationMode(imgIContainer::kNormalAnimMode),
mDocTitle(nsnull), mDocURL(nsnull), mShrinkRatio(1.0), mXMost(0)
{
}
nsPrintObject::~nsPrintObject()
{
if (mPresContext) {
mPresContext->SetImageAnimationMode(mImgAnimationMode);
}
for (PRInt32 i=0;i<mKids.Count();i++) {
nsPrintObject* po = (nsPrintObject*)mKids[i];
NS_ASSERTION(po, "nsPrintObject can't be null!");
delete po;
}
if (mPresShell && !mSharedPresShell) {
mPresShell->EndObservingDocument();
mPresShell->Destroy();
}
if (mDocTitle) nsMemory::Free(mDocTitle);
if (mDocURL) nsMemory::Free(mDocURL);
}
//------------------------------------------------------------------
// Resets PO by destroying the presentation
nsresult
nsPrintObject::Init(nsIWebShell* aWebShell)
{
mWebShell = aWebShell;
mDocShell = do_QueryInterface(mWebShell);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
mDocShell->GetPresShell(getter_AddRefs(mDisplayPresShell));
NS_ENSURE_TRUE(mDisplayPresShell, NS_ERROR_FAILURE);
mDocShell->GetPresContext(getter_AddRefs(mDisplayPresContext));
NS_ENSURE_TRUE(mDisplayPresContext, NS_ERROR_FAILURE);
mDisplayPresShell->GetDocument(getter_AddRefs(mDocument));
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
return NS_OK;
}
//------------------------------------------------------------------
// Resets PO by destroying the presentation
void
nsPrintObject::DestroyPresentation()
{
mWindow = nsnull;
mPresContext = nsnull;
if (mPresShell) mPresShell->Destroy();
mPresShell = nsnull;
mViewManager = nsnull;
mStyleSet = nsnull;
}

Просмотреть файл

@ -1635,8 +1635,7 @@ nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
rv = shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
NS_ENSURE_SUCCESS(rv, rv);
// Flags should always include OutputSelectionOnly if we're coming from here:
@ -3092,10 +3091,7 @@ NS_IMETHODIMP nsSelection::SelectAll()
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
return rv;
nsIDocument *doc = shell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
rootContent = doc->GetRootContent();
@ -7479,16 +7475,10 @@ nsTypedSelection::NotifySelectionListeners()
PRInt32 cnt = mSelectionListeners.Count();
nsCOMPtr<nsIDOMDocument> domdoc;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetPresShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell)
{
rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
doc = 0;
domdoc = do_QueryInterface(doc);
}
domdoc = do_QueryInterface(shell->GetDocument());
short reason = mFrameSelection->PopReason();
for (PRInt32 i = 0; i < cnt; i++)
{

Просмотреть файл

@ -314,8 +314,8 @@ NS_METHOD nsDOMEvent::GetTarget(nsIDOMEventTarget** aTarget)
//Always want a target. Use document if nothing else.
nsIPresShell *presShell;
if (mPresContext && (presShell = mPresContext->GetPresShell())) {
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(presShell->GetDocument(getter_AddRefs(doc))) && doc) {
nsIDocument *doc = presShell->GetDocument();
if (doc) {
mTarget = do_QueryInterface(doc);
if (mTarget) {
*aTarget = mTarget;

Просмотреть файл

@ -1975,11 +1975,10 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
// from the focus controller.
nsCOMPtr<nsIDOMEventTarget> currentTarget(aCurrentTarget);
nsCOMPtr<nsIDOMElement> currentFocus;
nsCOMPtr<nsIDocument> doc;
nsIPresShell* shell = aPresContext->PresShell();
if (aEvent->message == NS_CONTEXTMENU_KEY) {
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsCOMPtr<nsPIDOMWindow> privWindow = do_QueryInterface(doc->GetScriptGlobalObject());
if (privWindow) {

Просмотреть файл

@ -1811,9 +1811,7 @@ nsEventStateManager::GetParentScrollingView(nsInputEvent *aEvent,
if (!aEvent) return NS_ERROR_FAILURE;
if (!aPresContext) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
aPresContext->PresShell()->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = aPresContext->PresShell()->GetDocument();
NS_ASSERTION(doc, "No document in prescontext!");
nsIDocument *parentDoc = doc->GetParentDocument();
@ -3039,8 +3037,7 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel)
parentAsDocShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsPresContext> presContext;
parentAsDocShell->GetPresContext(getter_AddRefs(presContext));
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
nsCOMPtr<nsIDOMWindowInternal> domwin(do_QueryInterface(doc->GetScriptGlobalObject()));
@ -3327,9 +3324,7 @@ nsEventStateManager::ShiftFocusInternal(PRBool aForward, nsIContent* aStart)
nsCOMPtr<nsIPresShell> parentShell;
parentDS->GetPresShell(getter_AddRefs(parentShell));
nsCOMPtr<nsIDocument> parent_doc;
parentShell->GetDocument(getter_AddRefs(parent_doc));
nsIDocument *parent_doc = parentShell->GetDocument();
nsIContent *docContent = parent_doc->FindContentForSubDocument(mDocument);
nsCOMPtr<nsPresContext> parentPC;
@ -4431,7 +4426,7 @@ void
nsEventStateManager::EnsureDocument(nsIPresShell* aPresShell)
{
if (!mDocument && aPresShell)
aPresShell->GetDocument(getter_AddRefs(mDocument));
mDocument = aPresShell->GetDocument();
}
void
@ -4963,8 +4958,7 @@ nsEventStateManager::IsFrameSetDoc(nsIDocShell* aDocShell)
nsCOMPtr<nsIPresShell> presShell;
aDocShell->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
if (htmlDoc) {
nsIContent *rootContent = doc->GetRootContent();

Просмотреть файл

@ -450,8 +450,7 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
// When display if first asked for, go ahead and get our colors set up.
nsIPresShell *presShell = aData->mPresContext->GetPresShell();
if (presShell) {
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (doc) {
nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
if (styleSheet) {

Просмотреть файл

@ -500,10 +500,8 @@ NS_IMPL_ISUPPORTS2(nsHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor)
static nsresult GetBodyColor(nsPresContext* aPresContext, nscolor* aColor)
{
nsCOMPtr<nsIDocument> doc;
nsIPresShell *shell = aPresContext->PresShell();
shell->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMHTMLDocument> domdoc = do_QueryInterface(doc);
nsCOMPtr<nsIDOMHTMLDocument> domdoc = do_QueryInterface(shell->GetDocument());
if (!domdoc)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLElement> body;

Просмотреть файл

@ -1383,10 +1383,9 @@ nsDocShell::GetCharset(char** aCharset)
*aCharset = nsnull;
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIDocument> doc;
GetPresShell(getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
*aCharset = ToNewCString(doc->GetDocumentCharacterSet());
if (!*aCharset) {
@ -1956,8 +1955,7 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel)
parentAsDocShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsPresContext> presContext;
parentAsDocShell->GetPresContext(getter_AddRefs(presContext));
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
nsCOMPtr<nsIScriptGlobalObject> sgo;
doc->GetScriptGlobalObject(getter_AddRefs(sgo));
@ -3364,17 +3362,12 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(treeItem));
docShell->GetPresShell(getter_AddRefs(presShell));
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDocShell> parentDS = do_QueryInterface(parentItem);
nsCOMPtr<nsIPresShell> pPresShell;
parentDS->GetPresShell(getter_AddRefs(pPresShell));
nsCOMPtr<nsIDocument> pDoc;
pPresShell->GetDocument(getter_AddRefs(pDoc));
nsIContent *shellContent = pDoc->FindContentForSubDocument(doc);
nsIContent *shellContent =
pPresShell->GetDocument()->FindContentForSubDocument(presShell->GetDocument());
NS_ASSERTION(shellContent, "subshell not in the map");
nsIFrame* frame;
@ -7017,8 +7010,7 @@ nsDocShell::SetCanvasHasFocus(PRBool aCanvasHasFocus)
GetPresShell(getter_AddRefs(presShell));
if (!presShell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (!doc) return NS_ERROR_FAILURE;
nsIContent *rootContent = doc->GetRootContent();

Просмотреть файл

@ -577,10 +577,7 @@ nsWebShell::OnLinkClickSync(nsIContent *aContent,
GetPresShell(getter_AddRefs(presShell));
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> currentDoc;
presShell->GetDocument(getter_AddRefs(currentDoc));
if (currentDoc != sourceDoc) {
if (presShell->GetDocument() != sourceDoc) {
// The source is not in the current document, don't let it
// execute any javascript in the current document.

Просмотреть файл

@ -960,8 +960,7 @@ nsEditor::GetDocumentCharacterSet(nsACString &characterSet)
nsresult rv = GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (doc) {
characterSet = doc->GetDocumentCharacterSet();
return NS_OK;
@ -980,8 +979,7 @@ nsEditor::SetDocumentCharacterSet(const nsACString& characterSet)
nsresult rv = GetPresShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (doc) {
doc->SetDocumentCharacterSet(characterSet);
return NS_OK;

Просмотреть файл

@ -3623,12 +3623,10 @@ nsHTMLEditor::ReplaceStyleSheet(const nsAString& aURL)
nsresult rv = GetCSSLoader(aURL, getter_AddRefs(cssLoader));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document;
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
rv = ps->GetDocument(getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);;
nsIDocument *document = ps->GetDocument();
if (!document) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIURI> uaURI;
@ -3871,15 +3869,10 @@ nsHTMLEditor::GetCSSLoader(const nsAString& aURL, nsICSSLoader** aCSSLoader)
return NS_ERROR_NULL_POINTER;
*aCSSLoader = 0;
nsresult rv;
nsCOMPtr<nsIDocument> document;
if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
rv = ps->GetDocument(getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);;
nsIDocument *document = ps->GetDocument();
if (!document) return NS_ERROR_NULL_POINTER;
NS_IF_ADDREF(*aCSSLoader = document->GetCSSLoader());

Просмотреть файл

@ -1329,10 +1329,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
nsCOMPtr<nsIDocumentEncoder> docEncoder (do_CreateInstance(formatType.get(), &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc;
rv = presShell->GetDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, rv);
nsIDocument *doc = presShell->GetDocument();
rv = docEncoder->Init(doc, aFormatType, aFlags);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -1329,9 +1329,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell,
mFocusedDocSelection->CollapseToStart(); // Hide old doc's selection
SetSelectionLook(startingPresShell, PR_FALSE, PR_FALSE); // hide caret
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (!doc) {
return NS_ERROR_FAILURE;
}
@ -1472,9 +1470,7 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (!doc) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -1546,8 +1546,8 @@ PRBool GetBGColorForHTMLElement( nsPresContext *aPresContext,
nsIPresShell* shell = aPresContext->GetPresShell();
if (shell) {
nsIDocument *doc = nsnull;
if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) {
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsIContent *pContent;
if ((pContent = doc->GetRootContent())) {
// make sure that this is the HTML element
@ -1576,7 +1576,6 @@ PRBool GetBGColorForHTMLElement( nsPresContext *aPresContext,
}
#endif
}// if content
NS_RELEASE(doc);
}// if doc
} // if shell

Просмотреть файл

@ -954,8 +954,7 @@ CantRenderReplacedElementEvent::~CantRenderReplacedElementEvent()
nsresult
CantRenderReplacedElementEvent::AddLoadGroupRequest(nsIPresShell* aPresShell)
{
nsCOMPtr<nsIDocument> doc;
aPresShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = aPresShell->GetDocument();
if (!doc) return NS_ERROR_FAILURE;
nsresult rv = nsDummyLayoutRequest::Create(getter_AddRefs(mDummyLayoutRequest), aPresShell);
@ -986,8 +985,7 @@ CantRenderReplacedElementEvent::RemoveLoadGroupRequest()
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (!presShell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (!doc) return NS_ERROR_FAILURE;;
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();

Просмотреть файл

@ -90,8 +90,8 @@ class nsIStyleSheet;
class nsCSSFrameConstructor;
#define NS_IPRESSHELL_IID \
{ 0x76e79c60, 0x944e, 0x11d1, \
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
{ 0xde106833, 0xf56c, 0x4062, \
{0x9c, 0x7c, 0x60, 0x67, 0x40, 0x7e, 0x88, 0x4a} }
// Constants uses for ScrollFrameIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -163,7 +163,6 @@ public:
NS_IMETHOD PopStackMemory() = 0;
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult) = 0;
NS_IMETHOD GetDocument(nsIDocument** aResult) = 0;
nsIDocument* GetDocument() { return mDocument; }
NS_IMETHOD GetPresContext(nsPresContext** aResult) = 0;

Просмотреть файл

@ -702,8 +702,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
if (mShell) {
// Remove ourselves as the charset observer from the shell's doc, because
// this shell may be going away for good.
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = mShell->GetDocument();
if (doc) {
doc->RemoveCharSetObserver(this);
}
@ -712,28 +711,26 @@ nsPresContext::SetShell(nsIPresShell* aShell)
mShell = aShell;
if (mShell) {
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) {
NS_ASSERTION(doc, "expect document here");
if (doc) {
nsIURI *baseURI = doc->GetBaseURI();
nsIDocument *doc = mShell->GetDocument();
NS_ASSERTION(doc, "expect document here");
if (doc) {
nsIURI *baseURI = doc->GetBaseURI();
if (mMedium != nsLayoutAtoms::print && baseURI) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
baseURI->SchemeIs("chrome", &isChrome);
baseURI->SchemeIs("resource", &isRes);
if (mMedium != nsLayoutAtoms::print && baseURI) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
baseURI->SchemeIs("chrome", &isChrome);
baseURI->SchemeIs("resource", &isRes);
if (!isChrome && !isRes)
mImageAnimationMode = mImageAnimationModePref;
else
mImageAnimationMode = imgIContainer::kNormalAnimMode;
}
if (!isChrome && !isRes)
mImageAnimationMode = mImageAnimationModePref;
else
mImageAnimationMode = imgIContainer::kNormalAnimMode;
}
if (mLangService) {
doc->AddCharSetObserver(this);
UpdateCharSet(doc->GetDocumentCharacterSet().get());
}
if (mLangService) {
doc->AddCharSetObserver(this);
UpdateCharSet(doc->GetDocumentCharacterSet().get());
}
}
}
@ -861,9 +858,8 @@ nsPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
// Now walk the content tree and set the animation mode
// on all the images
nsCOMPtr<nsIDocument> doc;
if (mShell != nsnull) {
mShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = mShell->GetDocument();
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
@ -1055,8 +1051,7 @@ nsPresContext::BidiEnabledInternal() const
PRBool bidiEnabled = PR_FALSE;
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::GetBidiEnabled");
if (mShell) {
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc) );
nsIDocument *doc = mShell->GetDocument();
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled");
if (doc) {
bidiEnabled = doc->GetBidiEnabled();
@ -1075,8 +1070,7 @@ void
nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
{
if (mShell) {
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc) );
nsIDocument *doc = mShell->GetDocument();
if (doc) {
doc->SetBidiEnabled(aBidiEnabled);
}

Просмотреть файл

@ -1084,7 +1084,6 @@ public:
NS_IMETHOD PopStackMemory();
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult);
NS_IMETHOD GetDocument(nsIDocument** aResult);
NS_IMETHOD GetPresContext(nsPresContext** aResult);
NS_IMETHOD GetViewManager(nsIViewManager** aResult);
nsIViewManager* GetViewManager() { return mViewManager; }
@ -2007,18 +2006,6 @@ PresShell::AllocateFrame(size_t aSize)
return mFrameArena.AllocateFrame(aSize);
}
NS_IMETHODIMP
PresShell::GetDocument(nsIDocument** aResult)
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mDocument;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
PresShell::GetPresContext(nsPresContext** aResult)
{
@ -4436,9 +4423,7 @@ PresShell::GetSelectionForCopy(nsISelection** outSelection)
*outSelection = nsnull;
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
if (!mDocument) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject());
@ -4487,9 +4472,7 @@ PresShell::DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aS
{
aOutValue.Truncate();
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
if (!mDocument) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsISelection> sel;
@ -4508,15 +4491,14 @@ PresShell::DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aS
}
// call the copy code
return nsCopySupport::GetContents(aMimeType, aFlags, sel, doc, aOutValue);
return nsCopySupport::GetContents(aMimeType, aFlags, sel,
mDocument, aOutValue);
}
NS_IMETHODIMP
PresShell::DoCopy()
{
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
if (!mDocument) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> sel;
nsresult rv = GetSelectionForCopy(getter_AddRefs(sel));
@ -4532,12 +4514,13 @@ PresShell::DoCopy()
return NS_OK;
// call the copy code
rv = nsCopySupport::HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard);
rv = nsCopySupport::HTMLCopy(sel, mDocument, nsIClipboard::kGlobalClipboard);
if (NS_FAILED(rv))
return rv;
// Now that we have copied, update the Paste menu item
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(doc->GetScriptGlobalObject());
nsCOMPtr<nsIDOMWindowInternal> domWindow =
do_QueryInterface(mDocument->GetScriptGlobalObject());
if (domWindow)
{
domWindow->UpdateCommands(NS_LITERAL_STRING("clipboard"));

Просмотреть файл

@ -90,8 +90,8 @@ class nsIStyleSheet;
class nsCSSFrameConstructor;
#define NS_IPRESSHELL_IID \
{ 0x76e79c60, 0x944e, 0x11d1, \
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
{ 0xde106833, 0xf56c, 0x4062, \
{0x9c, 0x7c, 0x60, 0x67, 0x40, 0x7e, 0x88, 0x4a} }
// Constants uses for ScrollFrameIntoView() function
#define NS_PRESSHELL_SCROLL_TOP 0
@ -163,7 +163,6 @@ public:
NS_IMETHOD PopStackMemory() = 0;
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult) = 0;
NS_IMETHOD GetDocument(nsIDocument** aResult) = 0;
nsIDocument* GetDocument() { return mDocument; }
NS_IMETHOD GetPresContext(nsPresContext** aResult) = 0;

Просмотреть файл

@ -702,8 +702,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
if (mShell) {
// Remove ourselves as the charset observer from the shell's doc, because
// this shell may be going away for good.
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = mShell->GetDocument();
if (doc) {
doc->RemoveCharSetObserver(this);
}
@ -712,28 +711,26 @@ nsPresContext::SetShell(nsIPresShell* aShell)
mShell = aShell;
if (mShell) {
nsCOMPtr<nsIDocument> doc;
if (NS_SUCCEEDED(mShell->GetDocument(getter_AddRefs(doc)))) {
NS_ASSERTION(doc, "expect document here");
if (doc) {
nsIURI *baseURI = doc->GetBaseURI();
nsIDocument *doc = mShell->GetDocument();
NS_ASSERTION(doc, "expect document here");
if (doc) {
nsIURI *baseURI = doc->GetBaseURI();
if (mMedium != nsLayoutAtoms::print && baseURI) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
baseURI->SchemeIs("chrome", &isChrome);
baseURI->SchemeIs("resource", &isRes);
if (mMedium != nsLayoutAtoms::print && baseURI) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
baseURI->SchemeIs("chrome", &isChrome);
baseURI->SchemeIs("resource", &isRes);
if (!isChrome && !isRes)
mImageAnimationMode = mImageAnimationModePref;
else
mImageAnimationMode = imgIContainer::kNormalAnimMode;
}
if (!isChrome && !isRes)
mImageAnimationMode = mImageAnimationModePref;
else
mImageAnimationMode = imgIContainer::kNormalAnimMode;
}
if (mLangService) {
doc->AddCharSetObserver(this);
UpdateCharSet(doc->GetDocumentCharacterSet().get());
}
if (mLangService) {
doc->AddCharSetObserver(this);
UpdateCharSet(doc->GetDocumentCharacterSet().get());
}
}
}
@ -861,9 +858,8 @@ nsPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
// Now walk the content tree and set the animation mode
// on all the images
nsCOMPtr<nsIDocument> doc;
if (mShell != nsnull) {
mShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = mShell->GetDocument();
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
@ -1055,8 +1051,7 @@ nsPresContext::BidiEnabledInternal() const
PRBool bidiEnabled = PR_FALSE;
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::GetBidiEnabled");
if (mShell) {
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc) );
nsIDocument *doc = mShell->GetDocument();
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled");
if (doc) {
bidiEnabled = doc->GetBidiEnabled();
@ -1075,8 +1070,7 @@ void
nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
{
if (mShell) {
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc) );
nsIDocument *doc = mShell->GetDocument();
if (doc) {
doc->SetBidiEnabled(aBidiEnabled);
}

Просмотреть файл

@ -162,9 +162,8 @@ NS_NewListControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsCOMPtr<nsIDocument> doc;
aPresShell->GetDocument(getter_AddRefs(doc));
nsListControlFrame* it = new (aPresShell) nsListControlFrame(aPresShell, doc);
nsListControlFrame* it =
new (aPresShell) nsListControlFrame(aPresShell, aPresShell->GetDocument());
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -1578,13 +1578,11 @@ nsTextControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
// Get the DOM document
nsCOMPtr<nsIDocument> doc;
nsresult rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
return rv;
nsIDocument *doc = shell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIDOMDocument> domdoc = do_QueryInterface(doc, &rv);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -1768,8 +1768,7 @@ nsBulletFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGro
if (!shell)
return;
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (!doc)
return;

Просмотреть файл

@ -610,8 +610,7 @@ SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext,
viewHasTransparentContent = PR_FALSE;
}
nsCOMPtr<nsIDocument> doc;
aPresContext->PresShell()->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = aPresContext->PresShell()->GetDocument();
if (doc) {
nsIContent *rootElem = doc->GetRootContent();
if (!doc->GetParentDocument() &&

Просмотреть файл

@ -1318,9 +1318,9 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr
}
nsIPresShell *shell = presContext->GetPresShell();
nsCOMPtr<nsIDocument> document;
nsIDocument *document = nsnull;
if (shell)
shell->GetDocument(getter_AddRefs(document));
document = shell->GetDocument();
// The anonymous <div> used by <inputs> never gets scrollbars.
nsCOMPtr<nsITextControlFrame> textFrame(do_QueryInterface(parent));

Просмотреть файл

@ -1522,9 +1522,7 @@ nsImageFrame::TriggerLink(nsPresContext* aPresContext,
if (!ps)
return;
nsCOMPtr<nsIDocument> doc;
rv = ps->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = ps->GetDocument();
if (doc) {
rv = securityManager->
CheckLoadURIWithPrincipal(doc->GetPrincipal(), aURI,
@ -1899,8 +1897,7 @@ nsImageFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGrou
if (!shell)
return;
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (!doc)
return;

Просмотреть файл

@ -1247,12 +1247,7 @@ nsObjectFrame::InstantiatePlugin(nsPresContext* aPresContext,
// Check to see if content-policy wants to veto this
if(aURI)
{
nsresult rv;
nsCOMPtr<nsIDocument> document;
rv = aPresContext->PresShell()->GetDocument(getter_AddRefs(document));
if (NS_FAILED(rv)) return rv;
nsIDocument *document = aPresContext->PresShell()->GetDocument();
if (! document)
return NS_ERROR_FAILURE;
@ -1260,13 +1255,13 @@ nsObjectFrame::InstantiatePlugin(nsPresContext* aPresContext,
//don't care if we can't get the originating URL
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; // default permit
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
aURI,
docURI,
mContent,
nsDependentCString(aMimetype ? aMimetype : ""),
nsnull, //extra
&shouldLoad);
nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
aURI,
docURI,
mContent,
nsDependentCString(aMimetype ? aMimetype : ""),
nsnull, //extra
&shouldLoad);
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
}
@ -2344,13 +2339,16 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg)
NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument)
{
nsresult rv = NS_ERROR_FAILURE;
if (!aDocument)
return NS_ERROR_NULL_POINTER;
*aDocument = nsnull;
if (nsnull != mContext) {
nsIPresShell *shell = mContext->GetPresShell();
if (shell)
rv = shell->GetDocument(aDocument);
NS_IF_ADDREF(*aDocument = shell->GetDocument());
}
return rv;
return NS_OK;
}
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
@ -2544,10 +2542,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result)
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
mContext->PresShell()->GetDocument(getter_AddRefs(doc));
rv = doc->GetBaseURI()->GetSpec(mDocumentBase);
rv = mContext->PresShell()->GetDocument()->GetBaseURI()->GetSpec(mDocumentBase);
}
if (rv == NS_OK)
*result = ToNewCString(mDocumentBase);

Просмотреть файл

@ -1635,8 +1635,7 @@ nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
rv = shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
NS_ENSURE_SUCCESS(rv, rv);
// Flags should always include OutputSelectionOnly if we're coming from here:
@ -3092,10 +3091,7 @@ NS_IMETHODIMP nsSelection::SelectAll()
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
return rv;
nsIDocument *doc = shell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
rootContent = doc->GetRootContent();
@ -7479,16 +7475,10 @@ nsTypedSelection::NotifySelectionListeners()
PRInt32 cnt = mSelectionListeners.Count();
nsCOMPtr<nsIDOMDocument> domdoc;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPresShell> shell;
nsresult rv = GetPresShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell)
{
rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
doc = 0;
domdoc = do_QueryInterface(doc);
}
domdoc = do_QueryInterface(shell->GetDocument());
short reason = mFrameSelection->PopReason();
for (PRInt32 i = 0; i < cnt; i++)
{

Просмотреть файл

@ -655,7 +655,7 @@ public:
{}
};
already_AddRefed<nsIDocument> GetDocument(nsPresContext* aPresContext);
nsIDocument* GetDocument(nsPresContext* aPresContext);
PRIntn PrepareUnicodeText(nsTextTransformer& aTransformer,
nsAutoIndexBuffer* aIndexBuffer,
@ -1325,15 +1325,15 @@ nsTextFrame::~nsTextFrame()
}
}
already_AddRefed<nsIDocument>
nsIDocument*
nsTextFrame::GetDocument(nsPresContext* aPresContext)
{
nsIDocument* result = nsnull;
nsIDocument *result = nsnull;
if (mContent) {
NS_IF_ADDREF(result = mContent->GetDocument());
result = mContent->GetDocument();
}
if (!result && aPresContext) {
aPresContext->PresShell()->GetDocument(&result);
result = aPresContext->PresShell()->GetDocument();
}
return result;
}
@ -2046,8 +2046,7 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsPresContext* aPresContex
// transformed when we formatted it, then there's no need to do all
// this and we should just render the text fragment directly. See
// PaintAsciiText()...
nsCOMPtr<nsIDocument> doc;
(*aPresShell)->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = (*aPresShell)->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
@ -2488,7 +2487,7 @@ nsTextFrame::GetPositionSlowly(nsPresContext* aPresContext,
*aNewContent = mContent;
aOffset =0;
}
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
nsIDocument *doc = GetDocument(aPresContext);
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
@ -3391,7 +3390,7 @@ nsTextFrame::GetPosition(nsPresContext* aCX,
SetFontFromStyle(acx, mStyleContext);
// Get the renderable form of the text
nsCOMPtr<nsIDocument> doc(GetDocument(aCX));
nsIDocument *doc = GetDocument(aCX);
nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aCX);
PRInt32 textLength;
// no need to worry about justification, that's always on the slow path
@ -3722,7 +3721,7 @@ nsTextFrame::GetPointFromOffset(nsPresContext* aPresContext,
}
// Transform text from content into renderable form
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
nsIDocument *doc = GetDocument(aPresContext);
nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext);
PRInt32 textLength;
PRInt32 numSpaces;
@ -4336,10 +4335,7 @@ nsTextFrame::CheckVisibility(nsPresContext* aContext, PRInt32 aStartIndex, PRInt
return NS_ERROR_FAILURE;
//get the document
nsCOMPtr<nsIDocument> doc;
rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
return rv;
nsIDocument *doc = shell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
//create texttransformer

Просмотреть файл

@ -1768,8 +1768,7 @@ nsBulletFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGro
if (!shell)
return;
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (!doc)
return;

Просмотреть файл

@ -610,8 +610,7 @@ SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext,
viewHasTransparentContent = PR_FALSE;
}
nsCOMPtr<nsIDocument> doc;
aPresContext->PresShell()->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = aPresContext->PresShell()->GetDocument();
if (doc) {
nsIContent *rootElem = doc->GetRootContent();
if (!doc->GetParentDocument() &&

Просмотреть файл

@ -954,8 +954,7 @@ CantRenderReplacedElementEvent::~CantRenderReplacedElementEvent()
nsresult
CantRenderReplacedElementEvent::AddLoadGroupRequest(nsIPresShell* aPresShell)
{
nsCOMPtr<nsIDocument> doc;
aPresShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = aPresShell->GetDocument();
if (!doc) return NS_ERROR_FAILURE;
nsresult rv = nsDummyLayoutRequest::Create(getter_AddRefs(mDummyLayoutRequest), aPresShell);
@ -986,8 +985,7 @@ CantRenderReplacedElementEvent::RemoveLoadGroupRequest()
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (!presShell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (!doc) return NS_ERROR_FAILURE;;
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();

Просмотреть файл

@ -1318,9 +1318,9 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr
}
nsIPresShell *shell = presContext->GetPresShell();
nsCOMPtr<nsIDocument> document;
nsIDocument *document = nsnull;
if (shell)
shell->GetDocument(getter_AddRefs(document));
document = shell->GetDocument();
// The anonymous <div> used by <inputs> never gets scrollbars.
nsCOMPtr<nsITextControlFrame> textFrame(do_QueryInterface(parent));

Просмотреть файл

@ -1522,9 +1522,7 @@ nsImageFrame::TriggerLink(nsPresContext* aPresContext,
if (!ps)
return;
nsCOMPtr<nsIDocument> doc;
rv = ps->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = ps->GetDocument();
if (doc) {
rv = securityManager->
CheckLoadURIWithPrincipal(doc->GetPrincipal(), aURI,
@ -1899,8 +1897,7 @@ nsImageFrame::GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGrou
if (!shell)
return;
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (!doc)
return;

Просмотреть файл

@ -1247,12 +1247,7 @@ nsObjectFrame::InstantiatePlugin(nsPresContext* aPresContext,
// Check to see if content-policy wants to veto this
if(aURI)
{
nsresult rv;
nsCOMPtr<nsIDocument> document;
rv = aPresContext->PresShell()->GetDocument(getter_AddRefs(document));
if (NS_FAILED(rv)) return rv;
nsIDocument *document = aPresContext->PresShell()->GetDocument();
if (! document)
return NS_ERROR_FAILURE;
@ -1260,13 +1255,13 @@ nsObjectFrame::InstantiatePlugin(nsPresContext* aPresContext,
//don't care if we can't get the originating URL
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; // default permit
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
aURI,
docURI,
mContent,
nsDependentCString(aMimetype ? aMimetype : ""),
nsnull, //extra
&shouldLoad);
nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
aURI,
docURI,
mContent,
nsDependentCString(aMimetype ? aMimetype : ""),
nsnull, //extra
&shouldLoad);
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
return NS_ERROR_CONTENT_BLOCKED_SHOW_ALT;
}
@ -2344,13 +2339,16 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg)
NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument)
{
nsresult rv = NS_ERROR_FAILURE;
if (!aDocument)
return NS_ERROR_NULL_POINTER;
*aDocument = nsnull;
if (nsnull != mContext) {
nsIPresShell *shell = mContext->GetPresShell();
if (shell)
rv = shell->GetDocument(aDocument);
NS_IF_ADDREF(*aDocument = shell->GetDocument());
}
return rv;
return NS_OK;
}
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
@ -2544,10 +2542,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result)
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc;
mContext->PresShell()->GetDocument(getter_AddRefs(doc));
rv = doc->GetBaseURI()->GetSpec(mDocumentBase);
rv = mContext->PresShell()->GetDocument()->GetBaseURI()->GetSpec(mDocumentBase);
}
if (rv == NS_OK)
*result = ToNewCString(mDocumentBase);

Просмотреть файл

@ -1084,7 +1084,6 @@ public:
NS_IMETHOD PopStackMemory();
NS_IMETHOD AllocateStackMemory(size_t aSize, void** aResult);
NS_IMETHOD GetDocument(nsIDocument** aResult);
NS_IMETHOD GetPresContext(nsPresContext** aResult);
NS_IMETHOD GetViewManager(nsIViewManager** aResult);
nsIViewManager* GetViewManager() { return mViewManager; }
@ -2007,18 +2006,6 @@ PresShell::AllocateFrame(size_t aSize)
return mFrameArena.AllocateFrame(aSize);
}
NS_IMETHODIMP
PresShell::GetDocument(nsIDocument** aResult)
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mDocument;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
PresShell::GetPresContext(nsPresContext** aResult)
{
@ -4436,9 +4423,7 @@ PresShell::GetSelectionForCopy(nsISelection** outSelection)
*outSelection = nsnull;
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
if (!mDocument) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(mDocument->GetScriptGlobalObject());
@ -4487,9 +4472,7 @@ PresShell::DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aS
{
aOutValue.Truncate();
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
if (!mDocument) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsISelection> sel;
@ -4508,15 +4491,14 @@ PresShell::DoGetContents(const nsACString& aMimeType, PRUint32 aFlags, PRBool aS
}
// call the copy code
return nsCopySupport::GetContents(aMimeType, aFlags, sel, doc, aOutValue);
return nsCopySupport::GetContents(aMimeType, aFlags, sel,
mDocument, aOutValue);
}
NS_IMETHODIMP
PresShell::DoCopy()
{
nsCOMPtr<nsIDocument> doc;
GetDocument(getter_AddRefs(doc));
if (!doc) return NS_ERROR_FAILURE;
if (!mDocument) return NS_ERROR_FAILURE;
nsCOMPtr<nsISelection> sel;
nsresult rv = GetSelectionForCopy(getter_AddRefs(sel));
@ -4532,12 +4514,13 @@ PresShell::DoCopy()
return NS_OK;
// call the copy code
rv = nsCopySupport::HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard);
rv = nsCopySupport::HTMLCopy(sel, mDocument, nsIClipboard::kGlobalClipboard);
if (NS_FAILED(rv))
return rv;
// Now that we have copied, update the Paste menu item
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(doc->GetScriptGlobalObject());
nsCOMPtr<nsIDOMWindowInternal> domWindow =
do_QueryInterface(mDocument->GetScriptGlobalObject());
if (domWindow)
{
domWindow->UpdateCommands(NS_LITERAL_STRING("clipboard"));

Просмотреть файл

@ -655,7 +655,7 @@ public:
{}
};
already_AddRefed<nsIDocument> GetDocument(nsPresContext* aPresContext);
nsIDocument* GetDocument(nsPresContext* aPresContext);
PRIntn PrepareUnicodeText(nsTextTransformer& aTransformer,
nsAutoIndexBuffer* aIndexBuffer,
@ -1325,15 +1325,15 @@ nsTextFrame::~nsTextFrame()
}
}
already_AddRefed<nsIDocument>
nsIDocument*
nsTextFrame::GetDocument(nsPresContext* aPresContext)
{
nsIDocument* result = nsnull;
nsIDocument *result = nsnull;
if (mContent) {
NS_IF_ADDREF(result = mContent->GetDocument());
result = mContent->GetDocument();
}
if (!result && aPresContext) {
aPresContext->PresShell()->GetDocument(&result);
result = aPresContext->PresShell()->GetDocument();
}
return result;
}
@ -2046,8 +2046,7 @@ nsresult nsTextFrame::GetTextInfoForPainting(nsPresContext* aPresContex
// transformed when we formatted it, then there's no need to do all
// this and we should just render the text fragment directly. See
// PaintAsciiText()...
nsCOMPtr<nsIDocument> doc;
(*aPresShell)->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = (*aPresShell)->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
@ -2488,7 +2487,7 @@ nsTextFrame::GetPositionSlowly(nsPresContext* aPresContext,
*aNewContent = mContent;
aOffset =0;
}
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
nsIDocument *doc = GetDocument(aPresContext);
// Make enough space to transform
nsAutoTextBuffer paintBuffer;
@ -3391,7 +3390,7 @@ nsTextFrame::GetPosition(nsPresContext* aCX,
SetFontFromStyle(acx, mStyleContext);
// Get the renderable form of the text
nsCOMPtr<nsIDocument> doc(GetDocument(aCX));
nsIDocument *doc = GetDocument(aCX);
nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aCX);
PRInt32 textLength;
// no need to worry about justification, that's always on the slow path
@ -3722,7 +3721,7 @@ nsTextFrame::GetPointFromOffset(nsPresContext* aPresContext,
}
// Transform text from content into renderable form
nsCOMPtr<nsIDocument> doc(GetDocument(aPresContext));
nsIDocument *doc = GetDocument(aPresContext);
nsTextTransformer tx(doc->GetLineBreaker(), nsnull, aPresContext);
PRInt32 textLength;
PRInt32 numSpaces;
@ -4336,10 +4335,7 @@ nsTextFrame::CheckVisibility(nsPresContext* aContext, PRInt32 aStartIndex, PRInt
return NS_ERROR_FAILURE;
//get the document
nsCOMPtr<nsIDocument> doc;
rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
return rv;
nsIDocument *doc = shell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
//create texttransformer

Просмотреть файл

@ -162,9 +162,8 @@ NS_NewListControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsCOMPtr<nsIDocument> doc;
aPresShell->GetDocument(getter_AddRefs(doc));
nsListControlFrame* it = new (aPresShell) nsListControlFrame(aPresShell, doc);
nsListControlFrame* it =
new (aPresShell) nsListControlFrame(aPresShell, aPresShell->GetDocument());
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -1578,13 +1578,11 @@ nsTextControlFrame::CreateAnonymousContent(nsPresContext* aPresContext,
// Get the DOM document
nsCOMPtr<nsIDocument> doc;
nsresult rv = shell->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv))
return rv;
nsIDocument *doc = shell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIDOMDocument> domdoc = do_QueryInterface(doc, &rv);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -1546,8 +1546,8 @@ PRBool GetBGColorForHTMLElement( nsPresContext *aPresContext,
nsIPresShell* shell = aPresContext->GetPresShell();
if (shell) {
nsIDocument *doc = nsnull;
if (NS_SUCCEEDED(shell->GetDocument(&doc)) && doc) {
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsIContent *pContent;
if ((pContent = doc->GetRootContent())) {
// make sure that this is the HTML element
@ -1576,7 +1576,6 @@ PRBool GetBGColorForHTMLElement( nsPresContext *aPresContext,
}
#endif
}// if content
NS_RELEASE(doc);
}// if doc
} // if shell

Просмотреть файл

@ -1744,8 +1744,7 @@ nsPrintEngine::IsParentAFrameSet(nsIWebShell * aParent)
// only check to see if there is a frameset if there is
// NO parent doc for this doc. meaning this parent is the root doc
if (shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {

Просмотреть файл

@ -93,7 +93,7 @@ nsPrintObject::Init(nsIWebShell* aWebShell)
mDocShell->GetPresContext(getter_AddRefs(mDisplayPresContext));
NS_ENSURE_TRUE(mDisplayPresContext, NS_ERROR_FAILURE);
mDisplayPresShell->GetDocument(getter_AddRefs(mDocument));
mDocument = mDisplayPresShell->GetDocument();
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
return NS_OK;

Просмотреть файл

@ -500,10 +500,8 @@ NS_IMPL_ISUPPORTS2(nsHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor)
static nsresult GetBodyColor(nsPresContext* aPresContext, nscolor* aColor)
{
nsCOMPtr<nsIDocument> doc;
nsIPresShell *shell = aPresContext->PresShell();
shell->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMHTMLDocument> domdoc = do_QueryInterface(doc);
nsCOMPtr<nsIDOMHTMLDocument> domdoc = do_QueryInterface(shell->GetDocument());
if (!domdoc)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMHTMLElement> body;

Просмотреть файл

@ -755,8 +755,7 @@ nsBoxFrame::IsInitialReflowForPrintPreview(nsBoxLayoutState& aState,
// Now, get the current URI to see if we doing chrome
nsIPresShell *presShell = aState.PresShell();
if (!presShell) return PR_FALSE;
nsCOMPtr<nsIDocument> doc;
presShell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = presShell->GetDocument();
if (!doc) return PR_FALSE;
nsIURI *uri = doc->GetDocumentURI();
if (!uri) return PR_FALSE;

Просмотреть файл

@ -627,10 +627,8 @@ nsBoxObject::GetDocShell(nsIDocShell** aResult)
// No nsIFrameFrame available for mContent, try if there's a mapping
// between mContent's document to mContent's subdocument.
nsCOMPtr<nsIDocument> doc;
mPresShell->GetDocument(getter_AddRefs(doc));
nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent);
nsIDocument *sub_doc =
mPresShell->GetDocument()->GetSubDocumentFor(mContent);
if (!sub_doc) {
return NS_OK;

Просмотреть файл

@ -666,8 +666,7 @@ nsImageBoxFrame::GetLoadGroup()
if (!shell)
return nsnull;
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (!doc)
return nsnull;

Просмотреть файл

@ -205,8 +205,7 @@ nsMenuBarFrame::SetActive(PRBool aActiveFlag)
if (!presShell)
break;
nsCOMPtr<nsIDocument> document;
presShell->GetDocument(getter_AddRefs(document));
nsIDocument *document = presShell->GetDocument();
if (!document)
break;
@ -226,12 +225,13 @@ nsMenuBarFrame::SetActive(PRBool aActiveFlag)
break;
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> focusedDoc;
windowInternal->GetDocument(getter_AddRefs(domDoc));
document = do_QueryInterface(domDoc);
if (!document)
focusedDoc = do_QueryInterface(domDoc);
if (!focusedDoc)
break;
presShell = document->GetShellAt(0);
presShell = focusedDoc->GetShellAt(0);
nsCOMPtr<nsISelectionController> selCon(do_QueryInterface(presShell));
// there is no selection controller for full page plugins
if (!selCon)

Просмотреть файл

@ -894,8 +894,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsPresContext* aPresContext,
// get the document and the global script object
nsIPresShell *presShell = aPresContext->PresShell();
nsCOMPtr<nsIDocument> document;
presShell->GetDocument(getter_AddRefs(document));
nsIDocument *document = presShell->GetDocument();
PRBool sizedToPopup = (mContent->Tag() != nsXULAtoms::tooltip) &&
(nsMenuFrame::IsSizedToPopup(aFrame->GetContent(), PR_FALSE));

Просмотреть файл

@ -152,9 +152,8 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
if(mTrackingMouseMove)
{
// get the document and the global script object - should this be cached?
nsCOMPtr<nsIDocument> document;
aPresContext->PresShell()->GetDocument(getter_AddRefs(document));
nsIScriptGlobalObject *scriptGlobalObject = document->GetScriptGlobalObject();
nsIScriptGlobalObject *scriptGlobalObject =
aPresContext->PresShell()->GetDocument()->GetScriptGlobalObject();
NS_ENSURE_TRUE(scriptGlobalObject, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem =

Просмотреть файл

@ -167,9 +167,8 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
if(mTrackingMouseMove)
{
// get the document and the global script object - should this be cached?
nsCOMPtr<nsIDocument> document;
aPresContext->PresShell()->GetDocument(getter_AddRefs(document));
nsCOMPtr<nsIDOMWindowInternal> window(do_QueryInterface(document->GetScriptGlobalObject()));
nsCOMPtr<nsIDOMWindowInternal>
window(do_QueryInterface(aPresContext->PresShell()->GetDocument()->GetScriptGlobalObject()));

Просмотреть файл

@ -2392,8 +2392,7 @@ DumpContentRecurse(nsIDocShell* aDocShell, FILE* out)
fprintf(out, "docshell=%p \n", aDocShell);
nsIPresShell* shell = GetPresShellFor(aDocShell);
if (nsnull != shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsIContent *root = doc->GetRootContent();
if (nsnull != root) {
@ -2855,8 +2854,7 @@ nsBrowserWindow::DispatchStyleMenu(PRInt32 aID)
nsIPresShell* shell = GetPresShell();
if (nsnull != shell) {
nsAutoString defaultStyle;
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsIAtom* defStyleAtom = NS_NewAtom("default-style");
doc->GetHeaderData(defStyleAtom, defaultStyle);
@ -2893,8 +2891,7 @@ nsBrowserWindow::DispatchStyleMenu(PRInt32 aID)
{
nsIPresShell* shell = GetPresShell();
if (nsnull != shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsAutoString defaultStyle;
nsIAtom* defStyleAtom = NS_NewAtom("default-style");

Просмотреть файл

@ -1084,8 +1084,7 @@ nsViewerApp::CreateRobot(nsBrowserWindow* aWindow)
{
nsIPresShell* shell = aWindow->GetPresShell();
if (nsnull != shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
nsCAutoString str;
nsresult rv = doc->GetDocumentURI()->GetSpec(str);

Просмотреть файл

@ -404,8 +404,7 @@ NS_IMETHODIMP nsXPBaseWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* a
nsIPresShell* shell;
GetPresShell(shell);
if (nsnull != shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
NS_IF_ADDREF(mContentRoot = doc->GetRootContent());
mDocIsLoaded = PR_TRUE;
@ -513,8 +512,7 @@ NS_IMETHODIMP nsXPBaseWindow::GetDocument(nsIDOMHTMLDocument *& aDocument)
nsIPresShell *shell = nsnull;
GetPresShell(shell);
if (nsnull != shell) {
nsCOMPtr<nsIDocument> doc;
shell->GetDocument(getter_AddRefs(doc));
nsIDocument *doc = shell->GetDocument();
if (doc) {
doc->QueryInterface(kIDOMHTMLDocumentIID,(void **)&htmlDoc);
}